Skip to content

SOAP Working with  #2

@Coder0951

Description

@Coder0951

Trying to use the SOAP example with a different site and only returning the xml from the site and not the response.


import concurrent.futures
import requests
from string import Template
import time
import xml.etree.ElementTree as ET

max_workers=20
inputfile='input.txt'
outputokfile='outputok.txt'
outputerrorfile='outputerror.txt'

url = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'

messagetemplate=Template(r"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:checkVat>
         <urn:countryCode>$countryCode</urn:countryCode>
          <urn:vatNumber>$vatNumber</urn:vatNumber>
      </urn:checkVat>
   </soapenv:Body>
</soapenv:Envelope>""")

headers = {'SOAPAction': 'checkVat','Content-Type':'text/xml;charset=UTF-8'}

# Retrieve a single page and report the URL and contents
def fire_post_request(url, data,timeout):
    start_time = time.time()
    response=requests.post(url, data=data,timeout=timeout,headers=headers)
    end_time=time.time() - start_time
    return response

def write(text,filename):
    file = open(filename, 'a')
    file.write(text)
    file.close()
data = messagetemplate.substitute(countryCode='AT',vatNumber='U123456789')

x = fire_post_request(url, data,60)
print(x.text)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions