Created
March 7, 2011 17:38
-
-
Save kgaughan/858851 to your computer and use it in GitHub Desktop.
HACK: Making the suds SOAP library not cause Telnic's SOAP server to choke on its requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from suds.client import Client | |
from suds.bindings import binding | |
import logging | |
USERNAME = 'username' | |
PASSWORD = 'password' | |
# Just for debugging purposes. | |
logging.basicConfig(level=logging.INFO) | |
logging.getLogger('suds.client').setLevel(logging.DEBUG) | |
# Telnic's SOAP server expects a SOAP 1.2 envelope, not a SOAP 1.1 envelope | |
# and will complain if this hack isn't done. | |
binding.envns = ('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope') | |
client = Client('client.wsdl', | |
username=USERNAME, | |
password=PASSWORD, | |
headers={'Content-Type': 'application/soap+xml'}) | |
# This will now work just fine. | |
client.service.someRandomMethod() |
I just wanted to leave a comment that isn't three years old that this appears to remain the best solution for SOAP 1.2 online. Using this to help get my Robot framework talking to a web service and it was a very handy snippet. Thanks for posting this. (And I couldn't find a way to message you on Stack Overflow, but thanks for pointing here from there.)
(And for me, shturm, it was line 19, the Content-Type.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it line 15 that makes the magic ?