[Tutor] SOAPpy and ZSI

Dan Thomas-Paquin danpaquin at yahoo.com
Wed Mar 26 21:30:27 CET 2008


Hi,
I've been tasked with setting up a basic SOAP client and I'm its been the most
frustrating python experience.

Here's the code:
from LoginService_services import *
import sys
from SOAPpy import SOAPProxy

# get a port proxy instance
loc = LoginServiceLocator()
port = loc.getLogin(in0='pbs_uen', in1='TDapi', in2='3dcarapi')

# create a new request
req = LoginRequest()

# call the remote method
resp = port.Login(req)

lr = resp.LoginReturn
lri0 = lr.get_element_items()[0]
service_url = lri0.Value

n = 'http://DefaultNamespace'
server = SOAPProxy(service_url, namespace=n)
server.config.dumpSOAPOut = 1
server.config.dumpSOAPIn = 1
server.config.dumpHeadersOut = 1
server.config.dumpHeadersIn = 1
test = server.greeting()

Notice I use ZSI (LoginService_services) for the Login and then SOAPpy for the post
log-in stuff (ZSI's wsdl2py script broke on the post log-in WSDL).
The login part works fine. It returns a URL with a session id appended. 

server.greeting() creates this envelope which I can see because of the dumps:
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>
<SOAP-ENV:Body>
<ns1:greeting xmlns:ns1="http://DefaultNamespace" SOAP-ENC:root="1">
</ns1:greeting>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

but then this error follows right after:

  File "generic_usage.py", line 34, in <module>
    test = server.greeting()
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/SOAPpy/Client.py",
line 470, in __call__
    return self.__r_call(*args, **kw)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/SOAPpy/Client.py",
line 492, in __r_call
    self.__hd, self.__ma)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/SOAPpy/Client.py",
line 363, in __call
    config = self.config)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/SOAPpy/Client.py",
line 252, in call
    raise HTTPError(code, msg)
SOAPpy.Errors.HTTPError: <HTTPError 500 Apple>

line 252 of Client.py is:

 if code == 500 and not \
               ( startswith(content_type, "text/xml") and message_len > 0 ):
            raise HTTPError(code, msg)


I can't tell if the server is returning the 500 error or if the transport is. I
honestly don't know where to go from here. I wouldn't doubt that the envelope isn't
correct for the service but I don't have access to any more info on that. Help much
appreciated.

Dan









"All men dream: but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity: but the dreamers of the day are dangerous men, for they may act their dreams with open eyes, to make it possible." -T. E. Lawrence -


More information about the Tutor mailing list