SOAP, Python, suds

iscarface picture iscarface · Mar 10, 2010 · Viewed 8k times · Source

Please advise library for working with soap in python.
Now, I'm trying to use "suds" and I can't undestand how get http headers from server reply
Code example:

from suds.client import Client
url = "http://10.1.0.36/money_trans/api3.wsdl"
client = Client(url)
login_res = client.service.Login("login", "password")

variable "login_res" contain xml answer and doesnt contain http headers. But I need to get session id from them.

Answer

Ishpeck picture Ishpeck · Mar 21, 2010

I think you actually want to look in the Cookie Jar for that.

client = Client(url)
login_res = client.service.Login("login", "password")
for c in client.options.transport.cookiejar:
   if "sess" in str(c).lower():
      print "Session cookie:", c

I'm not sure. I'm still a SUDS noob, myself. But this is what my gut tells me.