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

12 Comments to “Python/SOAP: second encounter”

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

    This is really disheartening.

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

    Did you try soaplib?

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

  3. bookstackNo Gravatar | 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 SmithNo Gravatar | 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. PaulNo Gravatar | March 9th, 2008 at 7:17 pm

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

  6. OlostaNo Gravatar | 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 GalyonNo Gravatar | 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 HristovNo Gravatar | 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. MichaelNo Gravatar | September 8th, 2008 at 5:36 am

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

    M

  11. LukeNo Gravatar | 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. vivekNo Gravatar | 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?

Leave a Comment

This site is using OpenAvatar based on