Monday, December 22, 2008

Python & SOAP

Generally speaking, python doesn't work well with SOAP services out there. I went through a bunch of tutorials, blog posts and massive Google-ing and found very little that worked. I have a M$ created SOAP service that I need to work with and it was just a pain.

I tried SOAPpy and ZSI and neither worked well. This left me with two options. Either I could work in the XML and use urllib to post the info, and consequently parse the results or I could use the PHP example. Both of these are gross. I ended up choosing the PHP idea. I put a php script in my Django app and called it (sending along the appropriate parameters) with from my Django view. It worked but man does this solution suck. I don't have appropriate error handling and there's the future compatibility issue. Yikes.

Anyway, I just kept my ear to the ground on this while my app was doing its thing. Until I read in a Google Group about the best answer for SOAP and Python. It's Suds (https://fedorahosted.org/suds/). Very easy to use, works perfectly and now it's python instead of PHP. My error handling works and I can feel a lot more comforatable about this app into the future.

If you're working with Python or Django and you need to consume a SOAP web service, do yourself a favor and get Suds. It's worth re-writing your old code.

1 comments:

MichaelMM said...

Hi Tim, thought I'd leave you a 'Thank You' for pointing me to Suds. I've haven't had much luck with SOAPpy or ZSI. Suds is so much easier. Thanks again.



Michael