Question

I am new to Python and currently am doing some translations from 2.7 to 3.2 after running 2to3 tool. One of the things that it couldn't fix is importing .xsd or .wsdl files. In 2.7 stuff like import content , where content is .xsd file in our directory seemed to work fine, but 3.2 cannot resolve this import. Does anybody know how can I do it?

Thanks!

Was it helpful?

Solution

It sounds like you're using a code generator on your .xsd and .wsdl files, correct?

Otherwise, I am confused what you mean when you say you cannot import a .xsd file; I don't think the Python import toolchain lets you do this without a new importer written specific for SOAP clients.

I recently had to communicate with a SOAP service and settled on suds.

The Client object in suds takes in a url to a wsdl file (I had to modify the url to use file:// in order to specify a local .wsdl file)

from suds.client import Client

a = Client(<url_to_wsdl_file>)
a.service.Method()

Hope this helps! I'm not sure if suds is Python 3 compliant, and a quick search didn't yield any useful information.

OTHER TIPS

Update for 2018:


Please use python-zeep instead of suds. It's well supported and actively developed. Suds is not. It's also much faster than suds


Sample, taken from the docs:

client = Client('http://www.webservicex.net/ConvertSpeed.asmx?WSDL')
result = client.service.ConvertSpeed(
    100, 'kilometersPerhour', 'milesPerhour')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top