It took me some time to figure out how to access a SOAP service protected by http digest authentication with urllib2 and suds. Here's what i came out with.
import urllib2 URL = 'http://example.com/service/' ah = urllib2.HTTPDigestAuthHandler() password = "mypass" ah.add_password(None,'http://www.example.com/','username',password) urllib2.install_opener(urllib2.build_opener(ah)) from suds.client import Client url = "http://www.example.com/wsdl/" client = Client(url) client.options.transport.urlopener = urllib2.build_opener(ah)
Nessun commento:
Posta un commento