Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 893
bitcycle Avatar asked Mar 31 '26 18:03

bitcycle


1 Answers

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)

like image 128
olly_uk Avatar answered Apr 02 '26 14:04

olly_uk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!