SOAPpy : How do I prefix items with a string in a SOAP/XML request?

Doug Farrell writeson at earthlink.net
Thu Aug 28 09:45:44 EDT 2003


Hi everyone,

I'm trying to build a program to interface to a SOAP/XML interface
provided by one of our vendors. This interface is built with MS SOAP
Toolkit 3.0, so I'm guessig they are running a .NET server. I'm trying
to build my program with Python as I've got to deploy on both Linux
and Sun/Solaris platforms. I'm developing on RedHat Linux 8.0 using
Python 2.2.1 and SOAPpy 0.10.2.

My experimental program almost works, but it isn't putting a necessary
prefix string on the XML items in the request. Here is the incorrect
request my program is generating:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:Init xmlns:ns1="http://some.web.service/" SOAP-ENC:root="1">
<authRequest>
<userPwd xsi:type="xsd:string">doug</userPwd>
<userID xsi:type="xsd:string">beta.grolier.doug</userID>
<profileID xsi:type="xsd:string"></profileID>
</authRequest>
</ns1:Init>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Here is what a working request should look like:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:Init xmlns:ns1="http://some.web.service/" SOAP-ENC:root="1">
<ns1:authRequest>
<ns1:userPwd xsi:type="xsd:string">doug</ns1:userPwd>
<ns1:userID xsi:type="xsd:string">beta.grolier.doug</ns1:userID>
<ns1:profileID xsi:type="xsd:string"></ns1:profileID>
</ns1:authRequest>
</ns1:Init>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

The difference is the 'ns1:' prefix in front of the userPwd, userID
and profileID items in the XML part of the request. Here is my sample
code that is generating the incorrect SOAP request:

#!/usr/bin/python

from SOAPpy import SOAPProxy
from SOAPpy import SOAPConfig

url = "http://some.web.service/direct/direct.asmx"
ns = "http://some.web.service/"
sa = "http://some.web.service/Init"

server = SOAPProxy(url, namespace=ns, soapaction=sa,
config=SOAPConfig(debug=1))

rsp = server._ns('ns1',
ns).Init(authRequest={'userID':'beta.grolier.doug', 'userPwd':'doug',
'profileID':''})

print "I'm outta here"

The degug=1 flag makes the program dump the XML requests/responses,
but then it crashes with a traceback because the message I'm getting
back is the server error message, not the expected response.

Does anyone have any ideas/suggestions on how I can tell the SOAPpy
module to add the 'ns1:' prefix to the the items in the request?

Thanks for your help,
Doug Farrell




More information about the Python-list mailing list