SimpleXMLRPCServer help
Brian Quinlan
brian at sweetapp.com
Fri Jul 12 12:38:16 EDT 2002
> help(SimpleXMLRPCServer) describe how to install an instance
> on the server:
>
> 2. Install an instance:
>
> class MyFuncs:
> def __init__(self):
> # make all of the string functions available through
> # string.func_name
> import string
> self.string = string
> def pow(self, x, y): return pow(x, y)
> def add(self, x, y) : return x + y
> server = SimpleXMLRPCServer(("localhost", 8000))
> server.register_instance(MyFuncs())
> server.serve_forever()
>
> BUT I cannot figure out the syntax to access it from a client point of
> view
In Python, you could call those functions like this:
from xmlrpclib import ServerProxy
s = ServerProxy('http://127.0.0.1:8000/')
s.pow(2,3)
s.add(2,3)
s.string.find('This is a test', 'test')
Cheers,
Brian
More information about the Python-list
mailing list