[Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?

Kent Johnson kent37 at tds.net
Thu Jun 23 13:20:15 CEST 2005

Ron Phillips wrote:
> I believe I've tried every setting known to man, in every script in 
> every little scrap of documentation available. XMLRPC requests using 
> SimpleXMLRPCRequestHandler -- no problem. But try to run them as a CGI 
> script, and I get system lock ups and that's all. No error codes; no 
> response whatsoever.
> I am using Python 2.3, Windows XP. I have run other CGI scripts in the 
> same directory, so I know that works.
> Has anyone used this successfully? Can you share demo server and client 
> scripts -- just an echo function or something?

The server example in the docs works for me with one correction:

## cgi-bin/xmlrpc.py

from SimpleXMLRPCServer import CGIXMLRPCRequestHandler

class MyFuncs:
    def div(self, x, y) : return x // y

handler = CGIXMLRPCRequestHandler()
handler.register_function(lambda x,y: x+y, 'add')

Run a simple CGI server by opening a command line to the parent dir of cgi-bin and running
python -c "import CGIHTTPServer; CGIHTTPServer.test()"


>From the command line:

 >>> import xmlrpclib
 >>> server = xmlrpclib.ServerProxy("http://localhost:8000/cgi-bin/xmlrpc.py")
 >>> server.system.listMethods()
['add', 'div', 'pow', 'system.listMethods', 'system.methodHelp', 'system.methodSignature']
 >>> server.add(1, 2)
 >>> server.pow(2, 10)

Using Python 2.4.1 on Windows 2000


More information about the Tutor mailing list