he library suds allows Python to make SOAP calls (that is, Python is the web service client).
We start by installing the suds library on an Ubuntu machine. The Python setuptools are needed to install suds.
sudo apt-get install python-setuptools
Then we download, unpack and install suds.
wget https://fedorahosted.org/releases/s/u/suds/python-suds-0.3.7.tar.gz
tar -zxvf python-suds-0.3.7.tar.gz
cd python-suds-0.3.7
sudo python setup.py install
The library is now ready to use. We start by importing the suds library, creating a client based on a SOAP url, and asking the library to print the SOAP web service methods that are available to us.
Normally you want to have the contents of the SOAP body. This is what suds provides in a very elegant way. However, you’re a bit stuck when you want to get something from the SOAP header. The author of suds realised this and made a backdoor to get the information anyway. We start by showing what the function last_received contains:
print client.last_received()
1000
Success
...
We can get portions of this data by doing some XML handling. Let’s say we want to print the resultCode: