ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: xmlrpc via proxy
by other posts by this author
Jul 31 2001 6:48AM messages near this date
Re: C/Cygwin/Python | RE: sleep command/function & searching the python docs
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


-- 
http://mail.python.org/mailman/listinfo/python-list

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved