[Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
joe@omc-international.com.au
joe at omc-international.com.au
Fri Jun 24 15:26:21 CEST 2005
Hi,
I managed to make it work with the following code:
#! /usr/bin/python
from SimpleXMLRPCServer import CGIXMLRPCRequestHandler
def plus(a,b):
return a + b
server = CGIXMLRPCRequestHandler()
server.register_function(plus)
server.handle_request()
Setting this to run from a cgi directory then using the following worked:
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy("http://127.0.0.1/~joe/xmlrpctest.cgi")
>>> s.plus(4,5)
9
Hope this helps
Joe
> Thanks for your response, Shuying Wang -- I was afraid no one even read
> the post. Now I see I wasn't clear.
> ----------------------------------------------------------------------------------
> Shuying Wang: I'm not sure what you're trying to do. But I run cgi
> scripts and make
> xmlrpc requests with xmlrpclib with a connection with
> xmlrpclib.Server(server_uri), though I'm only doing this client side.
> I'm not running the server as cgi.
> -----------------------------------------------------------------------------------
> I have a Python module that I am trying to expose via XMLRPC. I can get
> it running by assigning a port on the server using
> SimpleXMLRPCRequestHandler, but I would prefer to expose it through CGI
> if possible. This seems to be the stated purpose of the
> CGIXMLRPCRequestHandler, but I believe it is broken in some very serious
> way.
>
> The example code in the python online documentation calls a
> non-existant "div" function, so it was obviously a typing exercise, not
> actual code that anyone ever tested.
>
> In researching the module, I found several requests on various mailing
> lists for example code -- not a single one ever had a response. When
> I've seen this before, it has turned out that either: a) it is terribly
> difficult, or b)it is stupidly simple. Since this is a tutor list, and I
> have seen the members graciously answer some questions that seemed
> pretty simple, I thought I'd post it here.
>
> Since the only response (yours -- thanks again for responding!) was
> about xmlrpclib on the client side, not CGIXMLRPCRequestHandler on the
> server side, I can now conclude that it is terribly difficult, and slink
> off to publish using SOAP.
>
> Ron
>
>
> On 6/23/05, Ron Phillips <RPhillips at engineer.co.summit.oh.us> 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?
>>
>> Ron
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list