bitcycle
bitcycle

Reputation: 7812

How to get http response code from suds client when using faults

I'm using suds to call a Windows/WCF service like so:


# Setting up my client
client = Client(wsdl, transport = my_transport, location = url, faults = True, headers = my_soap_action_header, cache = None, wsse = my_http_security)

And, I'm getting a response something like this:


(Link){ Id = 12345 Type = "SomeType" }

I know from talking to the developer of the web service that the return value is the ID and type of the object returned, or it will throw an exception.

That said, I'm wondering how to interrogate the suds client for a normal http response code (e.g. 200).

Upvotes: 3

Views: 2234

Answers (1)

olly_uk
olly_uk

Reputation: 11875

I relise this is an old question but in case anyone else stumbles upon this i'll provide an answer.

you can setup the client with faults = False this then does not throw webFaults when error occur (so you'll have to implement your own error handeling) instead it returns a tuple with

(<status>, <returned-value>)

so for instance (taken from suds documentation)

client = client(url, faults=False)
result = client.service.addPerson(person)
print result

( 200, person ...)

hope that helps(if you ever look back here)

Upvotes: 5

Related Questions