More on Python, SOAPPosted on August 11th, 2004 2 comments
Following my earlier post on Python and SOAP, here is a simple SOAP server that returns a SOAP array (or, correspondingly, a Python list object):
import SOAPpydef getList():
list = ["Item 1", "Item 2", "Item 3"]
server = SOAPpy.SOAPServer((“localhost”, 9078)) # address tuple
print “SOAP Server running on localhost:9078″
server.registerFunction(getList) # expose the method
The SOAP method getList can be invoked using a simple SOAP client like the one below:
import SOAPpyserver = SOAPpy.SOAPProxy(“http://localhost:9078″)
list = server.getList()
print “Got: “, list
except Exception, e:
print “Caught exception: “, e
Next: WSDL. Or something.
For servers that return simple data types, and every web service I’ve seen so far does, what advantage does SOAP offer over XML-RPC?
Dan, for simple data types, I think it really shouldn’t matter if you go for XML-RPC instead of SOAP. The fact that it is heading towards W3C standardization (and it’s backed by Microsoft and IBM) may push more developers into switching over to SOAP.