SOAP.py
Duncan Grisby
dgrisby at uk.research.att.com
Tue Dec 18 11:09:05 EST 2001
[ I sent this post to the pywebsvcs list, but I thought I'd post it
here too. ]
I've just started trying some experiments with SOAP.py 0.9.7. I'm
having a problem with the server side that is so fundamental that I'm
sure I must be doing something wrong, but I can't see what.
Here is my server:
---------------
import SOAP
SOAP.Config.dumpSOAPOut = 1
def echo(s):
return "Hello " + s
server = SOAP.SOAPServer(("localhost", 8000))
server.registerFunction(echo)
server.serve_forever()
---------------
Not exactly complicated. Now, when I try a client, I get:
---------------
Python 2.2c1 (#1, Dec 17 2001, 19:20:56)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import SOAP
>>> server = SOAP.SOAPProxy("http://localhost:8000/")
>>> server.echo("Duncan")
"{'Result': 'Hello Duncan'}"
---------------
Note that that is a _string_ containing the Python representation of a
dictionary. Looking at the XML sent by the server:
*** Outgoing SOAP ******************************************************
<?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>
<echoResponse xsi:type="xsd:dict" SOAP-ENC:root="1">{'Result': 'Hello Duncan'}</echoResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
I'm sure that can't be right. The parsing code doesn't seem to
understand "xsd:dict". I'm sure it must be wrong to be transmitting a
dictionary using its Python representation.
If I apply the following patch, everything behaves the way the
documentation claims it should:
--- old_SOAP.py Mon Dec 17 20:26:09 2001
+++ SOAP.py Mon Dec 17 20:24:42 2001
@@ -3769,7 +3769,7 @@
config = self.server.config)
else:
resp = buildSOAP(kw =
- {'%sResponse' % method: {'Result': fr}},
+ {'%sResponse' % method: fr},
encoding = self.server.encoding,
config = self.server.config)
except Exception, e:
Is this the right thing to do? Am I barking up the wrong tree?
Does anyone have a suggestion of any other Python SOAP implementation
that is as simple to use as SOAP.py?
Cheers,
Duncan.
--
-- Duncan Grisby \ Research Engineer --
-- AT&T Laboratories Cambridge --
-- http://www.uk.research.att.com/~dpg1 --
More information about the Python-list
mailing list