Developer Forums | About Us | Site Map


Useful Lists

Web Host
site hosted by netplex

Online Manuals

Python SOAP libraries, Part 5
By Scott Archer and Uche Ogbuji - 2004-10-12 Page:  1 2 3

New developments for SOAPpy

As with its sister project, ZSI, SOAPpy has enjoyed a recent increase in activity and is now in version 0.11.3. This version includes WSDL support and many other improvements. Uche Ogbuji and Scott Archer try out this new version with the same complex Web service they tried accessing with ZSI 1.4.1 and ran into a different set of difficulties.

Two issues ago (see Resources), we took an updated look at ZSI, a Python Web services library that was covered in the past. This month, we shall look at updates in another such library. SOAPpy is another component of the "Web Services for Python" project. Version 0.11.3 is the latest and, as with ZSI, the most recent set of releases have added an impressive array of improvements and fixes. We have also been using SOAPpy to access Google's and Amazon's Web services in our recent articles on real-world Web services (see Resources).

Installing the software

We downloaded SOAPpy 0.11.3 for installation in Python 2.3.3, but before installing it, we had to download and install the following prerequisites:

  • fpconst - A Python library for special handling of IEEE 754 floating point numbers. Version 0.6.0 or more recent of fpconst is a new prerequisite for SOAPpy. We installed 0.6.0.
  • pyXML 0.8.3 or more recent is also required.

The software installed fine using the now standard python install from the unpacked directories. You can also install the following software in order to enable special capabilities. However, we did not choose to install the software.

  • pyGlobus to enable support for the Globus Alliance toolkit for grid computing (currently a substantial subset of the 2.2.4 and 2.4 versions of the Globus toolkit).
  • M2Crypto.SSL to enable support for SSL on SOAP servers. To enable SSL support for SOAP clients, you need SSL support compiled into Python. This is the default for Python 2.3+.

WSDL and a few more dateTime hiccups

As with ZSI, the recent feature of SOAPpy is WSDL support. The low-level APIs for SOAP access in SOAPpy are quite easy to use, but WSDL offers the promise of even less set-up code.

We tried to invoke a Web service that gave us some difficulty with ZSI 1.4.1. As we reported in the last article ("Python SOAP libraries, Part 4"):

Richard Hastings' Air Fare Quote Search is implemented in Apache Axis and searches some airline Web sites in real time to find the best available flight prices for a given itinerary (see resources). It aggregates and returns the results, sorted by price. The WSDL is at It defines two operations: getAirFareQuote and getAirlines. The former is used to execute the price search and takes 4 parameters: two W3C XML Schema Language Data Types (WXSDT) dateTime values giving the approximate start of the departure and end of the return flights and two WXSDT string values giving the three-letter airport codes between which the travel is to take place.

The set-up code is straightforward enough:

>>> import SOAPpy
>>> wsdl = '\
... /axis/services/SBGGetAirFareQuote?wsdl'
>>> proxy = SOAPpy.WSDL.Proxy(wsdl)


We attempted the straightforward positional parameter method invokation that we tried with ZSI. We had already entered the two dateTime parameters following the two string parameters right into a getAirFareQuote method invokation. So, we had to figure out how to create dateTime types. The document docs/simpleTypes.txt suggested creating instances of SOAP.DateTime, but this gives an AttributeError. As a result, we had to use SOAP.dateTimeType. This takes a Python time tuple. We created this tuple from ISO-8601 strings for readibility and picked parameters to give us a fare for travel to the upcoming PyCon in Washington, D.C., USA.

>>> proxy.getAirFareQuote(SOAPpy.dateTimeType(dep), SOAPpy.dateTimeType(ret), 'den', 'phl')
>>> import time
>>> ISO_8601_DATETIME = '%Y-%m-%dT%H:%M:%S'
>>> dep = time.strptime('2004-03-24T12:30:59', ISO_8601_DATETIME)
>>> dep_dt = SOAPpy.dateTimeType(dep)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/uogbuji/lib/lib/python2.3/site-packages/SOAPpy/", line 79, in __init__
    self._data = self._checkValueSpace(data)
  File "/home/uogbuji/lib/lib/python2.3/site-packages/SOAPpy/", 
    line 442, in _checkValueSpace
    raise ValueError, "invalid %s value - %s" % (self._type, e)
ValueError: invalid dateTime value - invalid type


After some trial and error to debug this rather cryptic error, we learned that SOAPpy does not like Python time tuples with -1 in the tm_isdst field. When this value is used, it generally indicates that the user wants the library to handle daylight savings time using sensible defaults. Since SOAPpy cannot handle the Python time tuples, we had to force everything to Greenwich Mean Time (GMT).

View Python SOAP libraries, Part 5 Discussion

Page:  1 2 3 Next Page: We need a little structure

First published by IBM developerWorks

Copyright 2004-2024 All rights reserved.
Article copyright and all rights retained by the author.