xml-rpc, O'Reilly cookbook example not working???
Meehan, Francois
Francois at iecholden.com
Mon Jan 6 21:59:51 EST 2003
Hi all,
In the process of learning Python, I bought the O'Reilly cookbook. I am
curious about xml-rpc, tried the example 13.2 and 13.3, they worked as long
as the client and server were on the same machine. Since rpc stands for
remote procedure, I tried to run with the client and server on different
machines.
The server does not respond to remote query, did also try telnetting the
ports, always gets "connection failed".
Any ideas?
Here is the first example code:
# server coder sxr_server.py
# needs Python 2.2 or the XML-RPC package from PythonWare
import SimpleXMLRPCServer
class StringFunctions:
def __init__(self):
# Make all of the Python string functions available through
# python_string.func_name
import string
self.python_string = string
def _privateFunction(self):
# This function cannot be called directly through XML-RPC because
# it starts with an underscore character '_', i.e., it's "private"
pass
def chop_in_half(self, astr):
return astr[:len(astr)/2]
def repeat(self, astr, times):
return astr * times
if __name__=='__main__':
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000))
server.register_instance(StringFunctions())
server.register_function(lambda astr: '_' + astr, '_string')
server.serve_forever()
===========================================================================
Regards,
Francois
More information about the Python-list
mailing list