[XML-SIG] Python Web Service Client Question
Joshua M. Goldfarb
jmg34 at cornell.edu
Wed Mar 24 16:11:27 EST 2004
Good afternoon,
I'm trying to write a simple web service client in Python. The
web service I'm trying to access is simple. It takes an integer and
returns a String. For some reason, when Python serializes the request, I
get this snippet (sanitized a bit):
....snip....
<SOAP-ENV:Body>
<methodName>
<empno>
<empno xsi:type="xsd:integer">123</empno>
</empno>
</methodName>
</SOAP-ENV:Body>
....snip....
The web service complains that it expects a simple type, and I can
understand why, given what I pasted above.
I can get Python to name the first <empno> whatever I want it to be
named, but I can't get Python to remove it. So, I guess there are two
approaches:
1) Figure out how to get Python to remove the outer <empno>
2) Name the outer <empno> something that the web service won't complain
about (i.e., <doNotParseMe>)
I can't figure out how to do either of the two approaches. Perhaps
there is also another approach (this is only my second day coding in
Python, though I'm already thoroughly amazed by the language).
Here is the Python web service client code:
from ZSI.client import Binding
from ZSI import TC
log_file = open('soaplog.txt', 'w+')
u = '/WebService.jws'
n = 'http://www.openuri.org/'
b = Binding(url=u, ns=n, host='localhost', port=7001, tracefile=log_file)
class MyInt:
def __init__(self, Empno):
self.empno=Empno
MyInt.typecode=TC.Struct(MyInt, [TC.Integer('empno')], 'empno')
empnum=MyInt(123)
result=b.methodName(empnum)[0]
print result
Thanks,
Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/xml-sig/attachments/20040324/c0e3e326/attachment.html
More information about the XML-SIG
mailing list