It looks like my experience in Python/SOAP programming no better than the first encounter. Here is the full story:

I am working on a client application to consume Microsoft SharePoint server web service recently. Since the client does not support scripting, I decided to develop a Python console application to ease my routine job.

The first two candidate are SOAPpy and ZSI. SOAPpy is the official library used in the DiveIntoPython, and ZSI is the succeeder of SOAPpy.

The first problem I have met in Python 2.5 environment is ZSI-2.0 depends on PyXML, which is not compatible to Python 2.5 though, so I migrated to ZSI-2.1_a1, and eventually get ZSI successfully imported. ZSI supports two approaches to use WSDL, I must admit I won’t consider any web service without WSDL.

  • ServiceProxy: dynamically build the method proxy in the run time
  • wsdl2py: generate the python code in compile time for later use

Neither of them works even for a simple web service from xmethods.com. Some type error or attribute exception is thrown when calling service method.

So I went back to the traditional SOAPpy. Though it is a little annoying to build fpconst, (thanks to easy_install to make it less painful), I really love the SOAPpy’s API, simple and stupid:

from SOAPpy import WSDL          
wsdlFile = ‘http://www.xmethods.net/sd/2001/TemperatureService.wsdl’)
server = WSDL.Proxy(wsdlFile)
server.foo(‘bar’)

However, the SOAPpy generate wrong SOAP message. Once the type is declared as sequence, the SOAPpy would insert tag as the container, that failed the service provider.

Don’t forget we have not touched the authentication, NTLM, the default certification policy used in most of the SharePoint server in the Intranet. This is really a long way to go.

UPDATE: Moved to Web category, so it won’t pollute the Gentoo Planet.

UPDATE: Thanks to Lawrence’s advice, I did try soaplib tonight last night. It is really a promising library for SOAP, the parser is based upon cElementTree, so it is supposed fast and memory-friendly. Once you build the service provider, Bang, you already get the consumer application. The only problem is there is no official support for WSDL. wsdl2py in ext package seems promising, it is under active development and should not be used in a production scenario, and checked-in 1 year ago. No wonder there are tons of errors in WSDL parsing. I just wonder optio developers may have a private code repository for daily check-in, and they may sync their work to the public from time to time.

Once I finish WSDL specification, I may refactor the wsdl2py module.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

15 Comments to “Python/SOAP: second encounter”

  1. DeanG | January 15th, 2008 at 2:09 pm

    This is really disheartening.

  2. Lawrence Oluyede | January 16th, 2008 at 6:27 am

    Did you try soaplib?

    http://trac.optio.webfactional.com/

  3. bookstack | January 16th, 2008 at 11:55 pm

    To DeanG:

    My fault, I should not post it in Gentoo category. Fixed already.
    BTW, I am just Tell the Truth, the Whole Truth, and Nothing but the Truth.

  4. Kevin Smith | February 9th, 2008 at 1:10 pm

    The example can’t work since http://www.xmethods.net/sd/2001/TemperatureService.wsdl
    throws a 404 not found.

    Seems like all the xmethods demo service are out of commission.

  5. Paul | March 9th, 2008 at 7:17 pm

    Are you saying that Python cannot be used to access SharePoint services? This is sad.

  6. Olosta | March 14th, 2008 at 3:03 am

    I was begining to be despair like you when I found this lib : https://fedorahosted.org/suds. I have not tested it extensively but it looks very promising.

  7. Refactor the Life » Blog Archive » Suds makes the soapy world less slippery | April 5th, 2008 at 10:26 am

    [...] the last post, I was whining about the bumps in the road when trying to consume a SOAP web service using python. [...]

  8. Jason Galyon | April 20th, 2008 at 12:23 pm

    Suds looks from my initial glance to be the most Pythonic way of dealing with SOAP Web Services as a client.

    Unfortunately, I can not yet get it to work with a .NET (asmx extension) web service.

    I have not tried the sharepoint communication with our servers at work yet. That is next.

    I have high hopes for Suds.

  9. Dimitri Hristov | April 25th, 2008 at 12:25 am

    I tried suds and it’s the first SOAP lib I’ve seen just working. Didn’t have any luck with SOAPPy and ZSI.

  10. Michael | September 8th, 2008 at 5:36 am

    Good thread.
    Anyone to speak for a good library for implementing SOAP server in python?

    M

  11. Luke | November 23rd, 2008 at 9:35 pm

    Great thread – I am still trying to come to terms with the fact that there is so little decent support for web services in Python….I looked to Django/Python as an alternative to .Net and had high hopes…hopefully suds does the trick as soappy failed dismally when trying to call .net generated web services

  12. vivek | July 15th, 2009 at 3:24 am

    can you tell me , which one is better to use(SOAPpy or ZSI)?? and which one is faster?

  13. SharePoint Development Services | April 20th, 2011 at 5:29 am

    @vivek: SOAPpy is better if you want to set up simple web services that only use basic types. But ZSI is the way forward if you want to use more complex objects. There is no difinitive answer to your question I’m afraid!
    I enjoyed this post, although it did initially dishearten me!

  14. Victor | May 1st, 2011 at 2:26 am

    I use as server soaplib an as a client Suds it works good when I’m moving inside my own computer, but I have problems for acces from one computer of the same LAN… I am searching if it is problem of firewall, but I think that is disabled, and iptables… but doesnt work….

  15. isabella | May 11th, 2011 at 6:38 am

    The Python/SOAP programming is very interesting to learn. It is good to know that you like soaplib. I hope there is already official support for WSDL.someday.

Leave a Comment