Simple XML RPC Server Example with functions : XML RPC « Network « Python Tutorial






from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
from SocketServer import ForkingMixIn

class Math:
    def pow(self, x, y):
        return pow(x, y)

    def hex(self, x):
        return "%x" % x

    def sortlist(self, l):
        l = list(l)
        l.sort()
        return l

class ForkingServer(ForkingMixIn, SimpleXMLRPCServer):
    pass

serveraddr = ('', 8765)
srvr = ForkingServer(serveraddr, SimpleXMLRPCRequestHandler)
srvr.register_instance(Math())
srvr.register_introspection_functions()
srvr.register_function(int)
srvr.register_function(list.sort)      # Won't work!
srvr.serve_forever()








21.23.XML RPC
21.23.1.Creating an XML-RPC Server
21.23.2.Creating an XML-RPC Client
21.23.3.XML-RPC Basic Client
21.23.4.XML-RPC Introspection Client
21.23.5.Doc XML RPC Server Example
21.23.6.Simple XML RPC Server Example with functions
21.23.7.Simple XML RPC Server Basic Example
21.23.8.XML-RPC Basic Test Client
21.23.9.CGI Example