Simple CGI-XMLRPC failure

Diez B. Roggisch deets at nospam.web.de
Tue Jan 13 00:45:41 CET 2009


Mike MacHenry schrieb:
> I am having a difficult time understanding why my very simple
> CGI-XMLRPC test isn't working. I created a server to export two
> functions, the built-in function "pow" and my own identity function
> "i". I run a script to call both of them and the "pow" work fine but
> the "i" gives me an error that says my XMLRPC server doesn't support
> than name. Here is the code for both files and the output:
> 
> #!/usr/bin/env python
> #This file is /usr/lib/cgi-bin/roundwarerpc.py
> from SimpleXMLRPCServer import CGIXMLRPCRequestHandler
> def i(x):
>         return x
> server = CGIXMLRPCRequestHandler()
> server.register_function(pow)
> server.register_function(i)
> server.handle_request()
> 
> 
> #!/usr/bin/env python
> #This file is ~/test.py
> import xmlrpclib
> server = xmlrpclib.ServerProxy("http://localhost/cgi-bin/roundwarerpc.py")
> print server.pow(2,3)
> print server.i(10)
> 
> #This is the STDOUT and STDERR when running ~/test.py
> dskippy at dskippy-laptop:$ python test.py 8
> Traceback (most recent call last):
>   File "test.py", line 4, in <module>
>     print server.test(10)
>   File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
>     return self.__send(self.__name, args)
>   File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
>     verbose=self.__verbose
>   File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
>     return self._parse_response(h.getfile(), sock)
>   File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
>     return u.close()
>   File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
>     raise Fault(**self._stack[0])
> xmlrpclib.Fault: <Fault 1: '<type \'exceptions.Exception\'>:method "i"
> is not supported'>
> 
> Does anyone know what might be wrong with this?

This works.

---
import threading


from SimpleXMLRPCServer import SimpleXMLRPCServer

def i(x):
     return x

server = SimpleXMLRPCServer(('localhost', 10000))
server.register_function(pow)
server.register_function(i)
t = threading.Thread(target=server.serve_forever)
t.setDaemon(True)
t.start()

import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost:10000")
print server.pow(2,3)
print server.i(10)
---

So maybe i is somehow an instance-variable of CGIXMLRPCRequestHandler. 
What happens if you rename it?

Diez



More information about the Python-list mailing list