XML-RPC Question

Jesper Olsen jolsen at mailme.dk
Thu Mar 14 07:07:39 EST 2002


Has anyone used the SimpleXMLRPCServer class?

Setting up a server goes something like this:

    from SimpleXMLRPCServer import *

    class MyClass:
        def helloWorld(self):
            return "Hello World!"

        def echo(self, text):
            return text

    myob=MyClass()

    server=SimpleXMLRPCServer(("",50000))
    server.register_function(myob.helloWorld)
    server.serve_forever()

The server can now be accessed by a client, e.g.:

    import xmlrpclib

    srv=xmlrpclib.Server("http://localhost:50000")

    try:
        print srv.helloWorld()
        print srv.system.listMethods()
    except xmlrpclib.Error, v:
        print "Error", v

The first srv.helloWorld() call succeeds, but srv.system.listMethods() results
in a "Fault 1" exception "system.listMethods" is not supported...

Is there something wrong here, or does SimpleXMLRPCServer, not support
the listMethods() call?

Cheers
Jesper



More information about the Python-list mailing list