Need advice: XML-RPC
Skip Montanaro
skip at pobox.com
Thu May 31 16:46:19 EDT 2001
Franz> I'd like to start to research the world of XML, especially for
Franz> communication and data exchange (guess, this is what XML-RPC
Franz> means). And I'd like to do that using Python. Yet I'm a bit
Franz> uncertain how to tackle this.
Using the effbot's xmlrpclib module is simplicity itself:
>>> import xmlrpclib
>>> server = xmlrpclib.Server("http://betty.userland.com")
>>> print server.examples.getStateName(41)
South Dakota
On the server end of things it's not much more difficult. All you have to
do is subclass xmlrpcserver.RequestHandler and override the call method to
do what you want. Here's what the bare RequestHandler class emits:
% python xmlrpcserver.py
CALL echo ([2, 3, 4],)
localhost.localdomain - - [31/May/2001 15:44:26] "POST /RPC2 HTTP/1.0" 200 -
in response to the corresponding client-side execution:
>>> import xmlrpclib
>>> server = xmlrpclib.Server("http://localhost:8000")
>>> server.echo([2,3,4])
[2, 3, 4]
Grab it and start hacking!
--
Skip Montanaro (skip at pobox.com)
(847)971-7098
More information about the Python-list
mailing list