Python SOAP client with suds

The 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.

tar -zxvf python-suds-0.3.7.tar.gz
cd python-suds-0.3.7
sudo python 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.

import suds
url = ""
client = suds.client.Client(url)
print client

From the output of the last print command, we learn that there is a method called FindCountryAsString that takes one argument: the IP address.

print client.service.FindCountryAsString("")

And it shows (edited for readability):

<?xml version="1.0"?>

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()
<?xml version="1.0" encoding="UTF-8"?>
      <ResponseHeader xmlns="">

We can get portions of this data by doing some XML handling. Let’s say we want to print the resultCode:

print client.last_received().getChild("soap:Envelope").getChild("soap:Header").getChild("ResponseHeader").getChild("resultCode").getText()

21 thoughts on “Python SOAP client with suds

  1. Permalink  ⋅ Reply

    Julio Cesar Allasia

    March 2, 2010 at 1:26pm

    Hello!, I have a question: where do you use SUDS as an example? In a python interpreter? Thanks a lot!

    • Permalink  ⋅ Reply


      March 2, 2010 at 2:14pm

      Yes, the code parts that start with “import suds” must be used within the Python interpreter. You can type “python” on the command prompt and then type the text as shown on the site, or save the text to a file named and run it as “python” from the command prompt.

      • Permalink  ⋅ Reply

        Julio Cesar Allasia

        March 2, 2010 at 3:38pm

        Thanks a lot! I did it. Now i try to invoke from my instance in Plone. Bye

      • Permalink  ⋅ Reply


        February 20, 2012 at 8:11am


        I tried the example above and it works within python-suds-0.3.7 directory.
        However, the same file doesnt work from another directory.
        Do I need to change some path variables so that suds can be imported from anywhere?
        Any help in this regard would be highly appreciated.


        • Permalink  ⋅ Reply


          February 20, 2012 at 10:01am

          ignore my previous comment. reinstalled and it worked

  2. Permalink  ⋅ Reply

    Julio Cesar Allasia

    March 6, 2010 at 8:17am

    Hello again!, I tried to invoke a python function from my instance in plone, but i couldnt because the imports of suds return a error. Do you know how i must define it? This is my function:
    import suds (these line cause the error)
    def wsdl_AB(self):
    url = “”
    client = suds.client.Client(url)
    return client.service.getAgrovocCSLanguages()

    Thank you so much!

    • Permalink  ⋅ Reply


      March 6, 2010 at 10:21am

      I don’t have experience with Plone. Perhaps you can search for others that tried to add python modules to the Plone installation.

    • Permalink  ⋅ Reply

      Adam Coddington

      January 24, 2012 at 10:35pm

      You likely have not yet installed ‘suds’; you can get around that easily by running `pip install suds` or `easy_install suds`.

  3. Permalink  ⋅ Reply


    October 6, 2010 at 3:39am

    This worked great.
    Keep up the good work. Now I can integrate suds in my own application.

  4. Permalink  ⋅ Reply


    March 25, 2011 at 8:22am

    I am using Python 2.7.1 on Windows machine. I have installed suds module (04) but while importing I am getting below exception:
    ImportError: No module named suds

    Please Help

    • Permalink  ⋅ Reply


      July 22, 2011 at 1:54pm

      I had the same issue, it was on Redhat though, it turned out that the installer was placing the suds modules in the 2.4 dist and not the 2.6 which is what I’m using. Make sure suds is installed in the right directory

  5. Permalink  ⋅ Reply


    June 14, 2011 at 11:45am

    Hey thanks a lot!! it worked for me

  6. Permalink  ⋅ Reply


    January 4, 2012 at 2:41pm

    Thanks for sharing the examples – this is just what I needed.

    I am developing a SOAP server and I needed a way to automate the testing procedures – SUDS is very simple to use, so I’m sticking to it.

  7. Permalink  ⋅ Reply


    July 11, 2013 at 1:27pm

    Hi, We are using SUDs for calling SOAP Services but facing an issue while parsing the response we are getting. The service support MTOM and we are getting parsing error.

    We tried using the plugin and implemented “received” function following

    but its not coming into our hook and failing before that only. Any help would be appreciated.

  8. Permalink  ⋅ Reply


    September 3, 2013 at 5:09am

    Sorry for bothering your guys…. I know this is old thread… I followed the example but got the error messsage below. do you know how to figure out it? really appreciated if you can share anyting

  9. Permalink  ⋅ Reply


    May 7, 2014 at 6:00pm

    Warning. Check which is the latest version of SUDS before downloading with WGET!

  10. Permalink  ⋅ Reply


    May 12, 2014 at 8:25am

    Hi, I have a question. I was installed SUDS finished, and import suds. While there an error ” client = suds.client.Client(url)
    AttributeError: ‘module’ object has no attribute ‘client'” occurs when running ‘client = suds.suds.client.Client(url)’. Could you please help me handle it? Thanks a lot!

    • Permalink  ⋅ Reply


      June 6, 2016 at 9:54am

      the url you passed is not correct. pass the wsdl url like hjgashjf.kjhkjf.wsdl

  11. Permalink  ⋅ Reply


    June 6, 2016 at 9:52am

    How to send soap message when it requires use authentication. the header is like


  12. Permalink  ⋅ Reply


    April 11, 2018 at 9:24pm

    I’m keep getting error cannot import name client
    I install suds and I’m running python 2.7

  13. Permalink  ⋅ Reply


    September 17, 2019 at 2:30pm

    Hi i have tried this and got exception like Errorno-2

    from suds.client import Client
    url = “”
    client = Client(url)

    Returns Error:

Leave a Reply

Your email will not be published. Name and Email fields are required.