ZSI
I was playing with ZSI today and installed the example script in my Apache cgi-bin folder to try to create a simple SOAP service on top of CGI
#!"C:\Documents and Settings\Stuart\My Documents\Python\Python23\python.exe"
def hello():
return "Hello, world"
def echo(*args):
return args
def average(*args):
sum = 0
for i in args: sum += i
return sum / len(args)
from ZSI import dispatch
dispatch.AsCGI()
On the client side I made a script to call this service:
import sys
from ZSI.client import Binding
IN, OUT = sys.stdin, sys.stdout
b = Binding( port="8765", url="/cgi-bin/soaptest.py", tracefile=OUT)
print b.echo( )
print b.echo( "1", "2" )
print b.hello()
a = b.average(range(1,11))
assert a == 5
Notice that the port is set to 8765. I am forwarding the SOAP calls through MindReef SoapScope using the command
ssconfig -f 8765,localhost:80
At first the scripted failed at the fitst call as the request from the service had truncated XML. So, I went into ZSIs dispatch.py class and commented the line in the _CGISendXML() method where the Content-Length was being set. I'm not sure why the content length is causing a problem but it seems that it is a few characters too small and thus the reciever is only reading up to that point. I guess this might not happen on an English OS and may be related to me running the script on Japanese Windows XP.
Once I got the example running I had another problem. The example in the ZSI: The Zolera Soap Infrastructure
Release 1.5.1 documentation was expecting an arg list where really average just needs a list of numbers so I rewrote it as follows.
def average( integers ):
sum = 0
for i in integers:
sum += i
return sum / len(integers)
Later: Thinks, I need an easy way to format Python code in these postings..
Posted by stuartcw at July 4, 2004 03:18 PM