344

I've never used SOAP before and I'm sort of new to Python. I'm doing this to get myself acquainted with both technologies. I've installed SOAPlib and I've tried to read their Client documentation, but I don't understand it too well. Is there anything else I can look into which is more suited for being a SOAP Client library for Python?

Edit: Just in case it helps, I'm using Python 2.6.

osiris
  • 432
  • 5
  • 18
damon
  • 14,485
  • 14
  • 56
  • 75
  • 1
    Does it *have* to be SOAP, such as using pre-existing web services? Python's xmlrpclib is dead simple to use and I've migrated our SOAP services to XMLRPC with it. – Kirk Strauser Oct 16 '08 at 01:03
  • 27
    Sometimes one just want to connect to service that is ONLY provided over SOAP so yes - good python SOAP lib is something that one will sooner or later need. One won't have any chance to convince service provider to replace SOAP with something "cleaner"... – rombarcz Sep 23 '09 at 20:24
  • 2
    FYI: I opened a similar post that targets SOAP for **Python 3**: http://stackoverflow.com/questions/7817303/whats-the-best-soap-client-library-for-python-3-x – gecco Oct 19 '11 at 06:21
  • 1
    Look at Python Wiki for uptodate info: https://wiki.python.org/moin/WebServices – Mr. Napik Aug 22 '16 at 18:50

14 Answers14

406

Update (2016):

If you only need SOAP client, there is well maintained library called zeep. It supports both Python 2 and 3 :)


Update:

Additionally to what is mentioned above, I will refer to Python WebServices page which is always up-to-date with all actively maintained and recommended modules to SOAP and all other webservice types.


Unfortunately, at the moment, I don't think there is a "best" Python SOAP library. Each of the mainstream ones available has its own pros and cons.

Older libraries:

  • SOAPy: Was the "best," but no longer maintained. Does not work on Python 2.5+

  • ZSI: Very painful to use, and development is slow. Has a module called "SOAPpy", which is different than SOAPy (above).

"Newer" libraries:

  • SUDS: Very Pythonic, and easy to create WSDL-consuming SOAP clients. Creating SOAP servers is a little bit more difficult. (This package does not work with Python3. For Python3 see SUDS-py3)

  • SUDS-py3: The Python3 version of SUDS

  • spyne: Creating servers is easy, creating clients a little bit more challenging. Documentation is somewhat lacking.

  • ladon: Creating servers is much like in soaplib (using a decorator). Ladon exposes more interfaces than SOAP at the same time without extra user code needed.

  • pysimplesoap: very lightweight but useful for both client and server - includes a web2py server integration that ships with web2py.

  • SOAPpy: Distinct from the abandoned SOAPpy that's hosted at the ZSI link above, this version was actually maintained until 2011, now it seems to be abandoned too.
  • soaplib: Easy to use python library for writing and calling soap web services. Webservices written with soaplib are simple, lightweight, work well with other SOAP implementations, and can be deployed as WSGI applications.
  • osa: A fast/slim easy to use SOAP python client library.

Of the above, I've only used SUDS personally, and I liked it a lot.

Jakub Pastuszuk
  • 928
  • 4
  • 12
  • 31
Samat Jain
  • 15,758
  • 4
  • 20
  • 13
  • Python 2.5.2, SOAPpy 0.12.0 and my SOAP clients work. – bortzmeyer Oct 16 '08 at 09:45
  • Looks like you misspelled SOAPpy. Or do soappy and soapy both exist? Either way you might want to edit to clarify – amarillion May 15 '09 at 19:15
  • 2
    SOAPy and SOAPpy are actually different. I've edited to clarify, and turned the post into a community wiki. – Samat Jain May 21 '09 at 20:16
  • 17
    +1 for SUDS, great library! I ran into problems using SUDS with HTTPS web services behind a proxy. Turns out it is a known Python `urllib2` issue. See my answer for more details. – sstock Aug 06 '09 at 08:35
  • I've personally, had a lot of success with SOAPpy. Although, I've occasionally had to write some wrappers to fix some things. ( .NET consuming, WSDL serving ) – sfossen Oct 20 '10 at 15:41
  • suds could be great, but it has problems with ssl ((( – DataGreed Nov 23 '10 at 16:34
  • Suds also doesn't support multipart replies without our patch: https://fedorahosted.org/suds/ticket/308 – akaihola Nov 29 '11 at 08:43
  • 4
    I tried SUDs, but it went into an infinite loop when opening a WSDL; then python threw a recursion limit error. I found this open ticket regarding the issue: https://fedorahosted.org/suds/ticket/239 Apparently this was a library breaking bug 3 years ago, and still hasn't been fixed. – Buttons840 Feb 27 '12 at 22:05
  • How can you write a server using SUDS? Never seen any working examples. – t00ny Apr 09 '13 at 20:36
  • 11
    There's a maintained fork of SUDS at https://bitbucket.org/jurko/suds – Sjaak Trekhaak Jun 28 '13 at 12:10
  • 1
    I've started using SUDS today for fetching data only. It handled a basic apikey auth in the soap headers without any problems, and the responses were fairly easy to parse. The documentation was also fairy decent. – saccharine Sep 06 '13 at 00:15
  • SOAPpy was revived a bit and received a few updates in 2014. Check it out here: https://pypi.python.org/pypi/SOAPpy. – Joe L. Apr 08 '15 at 20:22
  • I used a suds-jurko, works with python 3.3. Great library indeed!! – Ward Apr 30 '15 at 13:11
  • Many of these seem outdated, but **osa** seems to be maintained, documented and easy to use. – Mikko Koho Dec 07 '15 at 16:56
  • 1
    Big thanks for coming back in 2016 and updating this! – WhyNotHugo Mar 10 '17 at 19:52
  • SUDS’ fedorahosted page is now not available. Also, there is a new Python3 version of it, available as [suds-py3](https://github.com/cackharot/suds-py3). – GergelyPolonkai Mar 01 '18 at 09:36
  • 1
    Update from 2018 - Zeep seems to be the way to go - most modern underlying libraries, extensive support. – Damian Jun 10 '18 at 18:36
  • In case there is anyone able to provide info on which of these is supporting Client side TLS certificates via HSM (PKCS11) it would be highly appreciated! – Petr Apr 16 '19 at 14:14
48

I followed the advice of other answers to this question and gave SUDS a try. After using it "in anger" I must agree: SUDS is very nice! Highly recommended!

I did run into trouble calling HTTPS-based web services from behind a proxy. At the time of this writing, this affects all Python web-service clients that use urllib2, so I'll document the solution here.

The urllib2 module shipping with python 2.6.2 and below will not issue a CONNECT to the proxy for HTTPS-over-HTTP-proxy sessions. This results in a long timeout, or if you are lucky, an error that looks like:

abort: error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

This was issue1424152 on the Python bug tracker. There are patches attached to the bug report that will fix this in Python 2.x and Python 3.x. The issue is already fixed.

ralf.w.
  • 1,676
  • 1
  • 24
  • 34
sstock
  • 1,586
  • 11
  • 11
19

I had good experience with SUDS https://fedorahosted.org/suds

Used their TestSuite as documentation.

  • 1
    SUDS is awesome! really easy to use, good docs, great stuff! – Sander Versluys Oct 05 '11 at 15:40
  • 1
    Maintained, python3 supported fork: [suds-jurko](https://bitbucket.org/jurko/suds). `pip install suds-jurko` – laffuste Jun 19 '15 at 03:00
  • I am trying to call async soap api with suds, working well but not getting any response, can someone help in that, hr my Q.: http://stackoverflow.com/questions/39227719/asynchronous-soap-api-call-using-python – Vikram Singh Chandel Aug 30 '16 at 13:35
11

SUDS is the way to go, no question about it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 5
    And it also fails on a large number of WSDL files. To back that claim up - the Bing maps API's for example, some of these fail and suds can't parse them. –  Jan 10 '11 at 10:17
  • 3
    i found SUDS supports SSL endpoints. – leonigmig May 06 '11 at 15:27
9

Just an FYI warning for people looking at SUDS, until this ticket is resolved, SUDS does not support the "choice" tag in WSDL:

https://fedorahosted.org/suds/ticket/342

see: suds and choice tag

Community
  • 1
  • 1
Doug
  • 32,844
  • 38
  • 166
  • 222
6

SUDS is easy to use, but is not guaranteed to be re-entrant. If you're keeping the WSDL Client() object around in a threaded app for better performance, there's some risk involved. The solution to this risk, the clone() method, throws the unrecoverable Python 5508 bug, which seems to print but not really throw an exception. Can be confusing, but it works. It is still by far the best Python SOAP client.

4

We released a new library: PySimpleSOAP, that provides support for simple and functional client/server. It goals are: ease of use and flexibility (no classes, autogenerated code or xml is required), WSDL introspection and generation, WS-I standard compliance, compatibility (including Java AXIS, .NET and Jboss WS). It is included into Web2Py to enable full-stack solutions (complementing other supported protocols such as XML_RPC, JSON, AMF-RPC, etc.).

If someone is learning SOAP or want to investigate it, I think it is a good choice to start.

reingart
  • 171
  • 1
  • 3
2

I believe soaplib has deprecated its SOAP client ('sender') in favor of suds. At this point soaplib is focused on being a web framework agnostic SOAP server ('receiver'). Currently soaplib is under active development and is usually discussed in the Python SOAP mailing list:

http://mail.python.org/mailman/listinfo/soap

2

In my conclusion we have this:

Soap client side:

use only Suds-jurko (updated 2016) suds is well maintained and updated.

UPDATE 06/2017: suds-jurko library is not updated and apparently abandoned,

I tested zeep library but got limitations around tokens, by now just support UsernameToken, i report a bug to create timestamp token and author update the code to fix it.

Zeep start good and has good documentation , so i recently migrated my code from suds to zeep and works fine.

Soap server side:

We have TGWS, soaplib (pysimplesoap not tested) IMHO use and help soaplib must be the choice.

Best regards,

  • Is there good documentation/samples for Suds-jurko? in the repo there are a few .rst files but not much in a way of documentation of how to use the library. – ierdna Jun 16 '17 at 23:12
1

As I suggested here I recommend you roll your own. It's actually not that difficult and I suspect that's the reason there aren't better Python SOAP libraries out there.

Community
  • 1
  • 1
Greg
  • 45,306
  • 89
  • 231
  • 297
1

suds is pretty good. I tried SOAPpy but didn't get it to work in quite the way I needed whereas suds worked pretty much straight away.

Pratik Patel
  • 119
  • 8
0

Could this help: http://users.skynet.be/pascalbotte/rcx-ws-doc/python.htm#SOAPPY

I found it by searching for wsdl and python, with the rational being, that you would need a wsdl description of a SOAP server to do any useful client wrappers....

Daren Thomas
  • 67,947
  • 40
  • 154
  • 200
0

We'd used SOAPpy from Python Web Services, but it seems that ZSI (same source) is replacing it.

Kirk Strauser
  • 30,189
  • 5
  • 49
  • 65
0

Im using SOAPpy with Python 2.5.3 in a production setting.

I had to manually edit a couple of files in SOAPpy (something about header code being in the wrong place) but other than that it worked and continues to do so very reliably.

carl
  • 1