Skip to content

Instantly share code, notes, and snippets.

@kgaughan
Created March 7, 2011 17:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgaughan/858851 to your computer and use it in GitHub Desktop.
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
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()
@shturm
Copy link

shturm commented Jan 2, 2014

Is it line 15 that makes the magic ?

@GeoffHadlington
Copy link

GeoffHadlington commented Jul 21, 2017

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