tags:

views:

144

answers:

0

I'm writing a SOAP client to talk to servers on our local network but our provider's WSDL references but doesn't import the SOAP encoding schema. We can fix this up with suds' ImportDoctor but doing so requires access to the internet to fetch the schema. Our internet access is via an HTTP proxy. If I set the $http_proxy environment variable this works but then the client tries to access the SOAP endpoint via the proxy. This does not work.

I need to use a proxy to get the SOAP schema but a direct connection to the local endpoint. I tried this, in the hope that creating proxyless transport for the SOAP endpoint would leave the transport for the schema to inherit the environment:

from suds.client import Client
from suds.transport.http import HttpTransport
from suds.xsd.doctor import ImportDoctor, Import

WSDL_URI = 'file:///path/to/wsdl'
SOAP_URI = 'https://server.example.com/path'

imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add('http://soap.zeus.com/zxtm/1.0/')
doctor = ImportDoctor(imp)

transport = HttpTransport()
proxy = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
transport.urlopener = opener

client = Client(WSDL_URI, doctor=doctor, transport=transport, location=SOAP_URI)

That didn't work either. It seems Client uses the supplied transport for both the schema download and SOAP endpoint.

How can I work around this?