例子:
Python RPC Server
import SimpleXMLRPCServer
class MyObject:
def sayHello(self):
return "hello ZQF, That is xmlprc Respond."
obj = MyObject()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 80))
server.register_instance(obj)
print "Listening on port 80"
server.serve_forever()
Python RPC Client
import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost:80")
words = server.sayHello()
print "result:" + words