I'm trying to call the Country capitals SOAP API to get the country capital on Python.
import requests
url = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL"
headers = {'content-type': 'text/xml'}
body = """<soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:web=http://www.oorsprong.org/websamples.countryinfo>
<soapenv:Header/>
<soapenv:Body>
<web:CapitalCity>
<web:sCountryISOCode>USA</web:sCountryISOCode>
</web:CapitalCity>
</soapenv:Body>
</soapenv:Envelope>"""
response = requests.post(url,data=body,headers=headers)
print(response.content)
I get a 200 OK response but it doesn't return the actual country capital, instead it just returns the entire content from the browser when you visit this http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL
It works without issues on SoapUI, do you know what I'm doing wrong on python?
zeepsoap client and it worked for me. Running your code I got status 500. Crafting your own SOAP seems like a heavy lift to me.client = Client(wsdl_url) result = client.service.CapitalCity(body)client.service.CapitalCity("USA"). SOAP is the transport, but its exposed as a regular API at the python level.