Hi,
I'm porting a small web service app from ZSI to suds. I'm having trouble connecting to an https:// service URL via a proxy.
If I use no proxy things seem ok; if I set up a proxy the connection appears to hang; an strace of the process suggests that the process connects to the proxy server and speaks raw SSL without the necessary:
CONNECT real-host:443 HTTP/1.0
that is needed as a preamble to hop through the proxy.
I'm using suds-0.3.8 and python-2.6.4; the former because it is current and the latter because it contains https-via-proxy support in urllib2.
The setup code looks like this:
client = Client(wsdlURL) if os.environ.get('WEBPROXY'): proxy = { 'http': os.environ['WEBPROXY'], 'https': os.environ['WEBPROXY'], } print "proxy =", `proxy` sys.stdout.flush() client.set_options(proxy = proxy) client.set_options(location = 'https://localhost/foo-service')
where $WEBPROXY contains "localhost:3128", wsdlURL is a file:// URL to my test WSDL and https://localhost/foo-service is a dummy URL to test the service before harassing a real instance.
I believe suds is not speaking to urllib2 correctly to activate the proxy tunnel.
The pre-suds app was making direct urllib2 calls and set things up like this (yes, a different environment variable):
proxy_support = urllib2.ProxyHandler({"http" : os.environ['http_proxy'], "https" : os.environ['http_proxy']}) opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener)
and things quietly worked. That doesn't seem to have any effect if I get suds to make the calls.
Can anyone suggest how I _should_ be setting this up for suds?
Cheers,
On 23Jan2010 18:01, I wrote: | I'm porting a small web service app from ZSI to suds. | I'm having trouble connecting to an https:// service URL | via a proxy. [...] | I'm using suds-0.3.8 and python-2.6.4; the former because it is current | and the latter because it contains https-via-proxy support in urllib2. | | The setup code looks like this: | | client = Client(wsdlURL) | if os.environ.get('WEBPROXY'): | proxy = { 'http': os.environ['WEBPROXY'], | 'https': os.environ['WEBPROXY'], | } | print "proxy =", `proxy` | sys.stdout.flush() | client.set_options(proxy = proxy) | client.set_options(location = 'https://localhost/foo-service') [...]
Just to note that if I set the UNIX environment variable https_proxy and don't use the suds proxy set_options() at all, things work just fine because python-2.6.4's urllib/urllib2 modules quietly do the right thing for this.
This will suffice for my intended use, but I'd like to know what the state of play is for using suds to control this, eg for when the envvar is not appropriate or when some specific calls must go via a specific proxy.
Cheers,