How to add http headers in suds 0.3.6?

Esabe picture Esabe · May 10, 2010 · Viewed 8.5k times · Source

I have an application in python 2.5 which sends data through suds 0.3.6.

The problem is that the data contains non-ascii characters, so I need the following header to exist in the soap message:

Content-Type="text/html; charset="utf-8"

and the header that exists in the SOAP message is just:

Content-Type="text/html"

I know that it is fixed in suds 0.4, but it requires Python2.6 and I NEED Python2.5 because I use CentOS and it needs that version. So the question is:

How could I change or add new HTTP headers to a SOAP message?

Answer

JK1 picture JK1 · Sep 28, 2011

At least in suds 0.4 (maybe earlier?) HTTP headers can also be passed in to the constructor or via the set_options method:

client = suds.client.Client(url, headers={'key': 'value'})
client.set_options(headers={'key2': 'value'})