Search This Blog

Loading...

Tuesday, January 27, 2009

Making suds not use a proxy

Suds is a very usable SOAP client library for python however it run in to trouble when you have a proxy configured and need to access the SOAP service without going through said proxy. The documentation doesn't mention this explicitly so here is how to talk it in to "doing the right thing"



from suds.client import Client
from suds.transport import HttpTransport
import urllib2
t = HttpTransport()
proxy = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
t.urlopener = opener
client = Client("http://path/to/wsdl", transport=t)

This should allow you to proceed as normal

4 comments:

hugo said...

Hi Peter,

I want to try your stuff. I have the following problem:
I have a soap client writen fro a customer but it has a clustered weblogic environment. I run into a error 500 when i want to get the wsdl from the server. Seems we need some adjustments to the cluster settings in weblogic but i cannot do this and it will take a long time to et it done. Now i was thinking to use a wsdl definition *from file* because the webservice is the same.

How should i proceed?

tx

saiful said...

hi peter,

thanks for your blog post, i was stuck with a mysterious problem and your post pointed the way to the solution...

one thing is that i got an error at the line: from suds.transport import HttpTransport..

I've found out that newer suds, such as suds-0.3.5 (and maybe 0.3.4 but I didn't check) the HttpTransport has moved. The correct form is:
from suds.transport.http import HttpTransport..

thanks!

mati said...

man, this is really helpful tip :) thanks!

शशांक शेखर "शशि" said...

Hi Peter,

Thank you very much.
Very useful information you have provided.

I have struggled a whole day to make a sample program (based on suds) work which was was working fine at my Lappy & stopped working at my work place due to proxy.

Thanks Again
Shasha