We were working with SOAP APIs in python. We need to dynamically pass the values in a request xml file.
test.xml file:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<Add xmlns="http://tempuri.org/">
<intA>3</intA>
<intB>4</intB>
</Add>
</Body>
</Envelope>
Python script:
from bs4 import BeautifulSoup
import requests
import xml.etree.ElementTree as ET
import lxml
url="http://www.dneonline.com/calculator.asmx?WSDL"
headers = {'content-type': 'text/xml'}
xmlfile = open('test.xml','r')
body = xmlfile.read()
response = requests.post(url,data=body,headers=headers)
print(response.text)
We need to pass intA and intB dynamically from python.