CGIXMLRPCRequestHandler example
Phoe6
orsenthil at gmail.com
Sun Mar 29 15:53:22 EDT 2009
I have the following CGIXMLRPCRequestHandler usage example. I have
both the server and the client in the same directory. I based this
following this example: http://mail.python.org/pipermail/python-list/2005-May/320696.html
Server Code: Foo.py
import os
import SimpleXMLRPCServer
class Foo:
def settings(self):
return os.environ
def echo(self, something):
return something
handler = SimpleXMLRPCServer.CGIXMLRPCRequestHandler()
handler.register_instance(Foo())
handler.handle_request()
And the Client which tries to Access it.
import xmlrpclib
server = xmlrpclib.ServerProxy('http://127.0.0.1/Foo.py')
print server
print dir(server)
sometext = 'Hello'
tup = tuple(sometext)
print tup
textcall = xmlrpclib.dumps(tup, ("server.echo"))
print textcall
print server.echo("Hello")
When I call the Client, the call fails at server.echo("Hello") and
says Connection Refused.
socket.error: [Errno 111] Connection refused
Should I do more? The handler is waiting for the requests, but do I
need to run a server or anything? Any pointers appreciated.
Thank you,
Senthil
More information about the Python-list
mailing list