Python & SOAP - new hope

2009-09-25 od romanb python, soap

For long time I've been postponing porting of one API I work with from PHP to Python because I've heard Pythons SOAP support is awful but eventually I had to do it. SOAPpy was first failure - it couldn't handle WSDL defined types but should I expect anything from lib with version number 0.12.0_rc1 that wasn't updated since 4 years?

Next in line was little fresher ZSI. I say little because its last version was dated November 2007. It was better than SOAPpy, it correctly formated and encoded outgoing message but when response was received with same data type that was sent ZSI couldn't handle it.

After about 6 hours of debugging and forcing ZSI to work with that data type I thought "So well supported (library-wise) language like Python cannot have this particular technology supported so bad" and I started digging again. I stumbled upon hundreds of opinions like "SOAP sucks! so why you want to implement it? use REST or anything but not SOAP". Well, if it were up to me I would do it RESTfull but it wasn't! I was provided with access to third party application, they weren't able to give me anything else so I have to live with it - they won't add another API just because I use language that has bad support for protocol of their choice and many other popular languages (like PHP or Ruby) support it just like that.

And then I found it. On StackOverflow if found guy with same problem as mine. Answer he got was "use suds - it really works". I've given it a try and it works. Include, 2 lines of code and? works like charm, uses WSDL defined types, enumeration, service inspection (with type requirements) by simple "print object", unicode and so on...

So if you really need to use SOAP in Python then I recommend use suds.