xmlrpc via proxy
abulka at netspace.net.au
abulka at netspace.net.au
Tue Jul 31 02:48:06 EDT 2001
Thanks Jeff, for the url to your proxy code - this code happens to be the code
I was adapting !
Your code works OK for
betty = Server("http://betty.userland.com", transport=UrllibTransport())
but fails for
meerkatsvr = Server("http://www.oreillynet.com/meerkat/xml-rpc/server.php",
transport=UrllibTransport())
giving the following exception
Traceback (innermost last)
File "c:\\xmlrpc work\python xmlrpc server\andyrpc1.py", line 40, in ?
print meerkatsvr.system.listMethods()
Fault: <Fault 103: 'XML error: no element found at line 1'>
I am also getting a similar error message attempting to communicate
with 'http://xmlrpc-c.sourceforge.net/api/sample.php' as per the python example
at XML-RPC HOWTO at http://xmlrpc-c.sourceforge.net/xmlrpc-howto/xmlrpc-howto-
python-client.html
Thus it seems your code works ok for http://betty.userland.com but not for the
other two ? Here is the code for your xmlrpc_urllib_transport.py with a
couple of extra lines which is me attempting to talk to meerkatsvr.
Any further thoughts by you or anyone else would be appreciated!
import xmlrpclib
class UrllibTransport(xmlrpclib.Transport):
'''Handles an HTTP transaction to an XML-RPC server via urllib
(urllib includes proxy-server support)
jjk 07/02/99'''
def request(self, host, handler, request_body):
'''issue XML-RPC request
jjk 07/02/99'''
import urllib
# ANDY added his proxy as parameter to urllib.FancyURLopener()
urlopener = urllib.FancyURLopener( {'http' : 'www-
proxy.BLAH.au:8080' } )
urlopener.addheaders = [('User-agent', self.user_agent)]
# probably should use appropriate 'join' methods instead
of 'http://'+host+handler
f = urlopener.open('http://'+host+handler, request_body)
return(self.parse_response(f))
from xmlrpc_urllib_transport import UrllibTransport
from xmlrpclib import Server
betty = Server("http://betty.userland.com", transport=UrllibTransport())
print betty.examples.getStateName(41) # WORKS OK
# ANDY added extra code to talk to meerkatsvr
from pprint import pprint
meerkatsvr = Server("http://www.oreillynet.com/meerkat/xml-rpc/server.php",
transport=UrllibTransport())
print "Now attempting to communicate with meerkat server"
print meerkatsvr.system.listMethods() # EXCEPTION RASIED - why?
- Andy
> > I'm trying to get xmlrpc to work through a firewall/proxy.
>
> I wrote a urllib transport for XML-RPC a couple years ago. It
> worked then, but I can't test it now because I no longer have
> to deal with a proxy firewall :-)
>
> Look for:
> xmlrpc_urllib_transport.py
> at:
> http://starship.python.net/crew/jjkunce/
>
> --Jeff
-------------------------------------------------
This mail sent through IMP: www.netspace.net.au
More information about the Python-list
mailing list