Python is not as fortunate as other languages when it comes to supporting the SOAP protocol. In the past, there were a few initiatives and projects that attempted to implement SOAP libraries into Python, but most were abandoned. Currently the most active and mature project is the Zolera SOAP Infrastructure (ZSI).
In most Linux distributions, this package is named python-ZSI and is available to install from the distribution's default package manager. If you choose to install the ZSI package from source, it can be found at http://pywebsvcs.sourceforge.net/.
There are two ways to access SOAP services from Python using ZSI:
• Service methods can be accessed through the ServiceProxy class, which is part of the ZSI library. When you create an object of this class all remote functions are available as methods of this object instance. This is a convenient way of accessing all services, but it requires you to generate type codes and define namespaces manually, which is a lot of work.
• Another way of accessing the SOAP interface is to use the wsdl2py tool. This tool reads the WSDL definition of the service and generates two modules: one with typecode information and another containing service methods.
I prefer using the second method, because it relieves me from having to define type codes and memorize namespaces. When using the ServiceProxy class , the user must explicitly define the namespace of the procedure. Furthermore, the type code of the request object must be compatible with the type defined in the WSDL, and this type code has to be crafted manually, which can become a real pain with services that use complicated data structures.
Was this article helpful?