Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > PYTHON TUTORIALS > PYTHON SOAP LIBRARIES, PART 3


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

Python SOAP libraries, Part 3
By Mike Olson and Uche Ogbuji - 2004-09-28 Page:  1 2 3

SOAP.py and ZSI can swap roles

In this installment of The Python Web services developer, Mike Olson gets back to writing some Python code. This column will revisit the example code from the fifth and sixth columns in this series, in which Mike and Uche Ogbuji talked about SOAP.py and ZSI, two available SOAP implementations in Python. Mike will continue the examination of these libraries and see how they interact with each other.

One of the promises of Web services is interoperability. As we explained in previous columns, Web services built with different programming languages and on different platforms should work together just as well as services provided by the same programming language. In this installment of The Python Web services developer, I will take the client and server for the calendar Web service that we implemented in previous articles in this column and see how they interoperate with each other.

To use the samples within this article, follow the installation steps for SOAP.py in the fifth installment in this series and for ZSI in the sixth. (You should review both those articles for background on SOAP.py and ZSI; you can find links to them in the Resources section.) As a side note, a newer version of ZSI has recently become available: version 1.2 was released in March of this year. The samples presented in this column do work with both ZSI 1.1 and 1.2. For those interested in upgrading, see the Resources section below for a URL where you can download the latest version. Installation uses standard distutils commands. If you have a previous version of ZSI installed, you should remove it first to avoid conflicts. To install the new version, untar the distribution and change into the ZSI-1.2 directory. Execute the install command as follows:



[molson@penny ZSI-1.2]# python setup.py install

Flipping it around: ZSI server, SOAP.py client

The first thing you need to do to in order to test a SOAP.py client with the ZSI server is to write the SOAP.py client. If you remember, we wrote a very low-level client to test the SOAP.py server using httplib (see the Resources for the sixth column on ZSI). Since you want to see how SOAP.py interacts with ZSI, this will not do. A quick client can be written to use your calendar Web service, as shown in Listing 2.

Listing 2. Updated ZSI client


#!/usr/bin/env python

import sys

#Import the SOAP.py machinery
from WebServices import SOAP

CAL_NS = "http://uche.ogbuji.net/eg/ws/simple-cal"


remote = SOAP.SOAPProxy(
    "localhost:8888",
    #namespace=CAL_NS,
    soapaction=""
)


print remote.getMonth(2002,2)

This client is implemented similarly to the curses client from the fifth column. One thing to note is that the namespace argument to the SOAPProxy is commented out. Just as the default implementation of the ZSI client was not namespace aware, the server is not either.

Again, to run the sample scripts, start the SOAP.py server in one window:


python zsi-server.py

And the ZSI client in a second window:


python soappy-client.py

As expected (since this client was written specifically to communicate with the SOAP.py server) you get back a calendar for February 2002.



View Python SOAP libraries, Part 3 Discussion

Page:  1 2 3 Next Page: ZSI and namespaces

First published by IBM developerWorks


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