Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python SUDS return type other than XML

Tags:

python

json

suds

I am working with a somewhat non-standard SOAP webservice. Most of the calls to the webservice return the standard SOAP XML as you would expect, but one call in particular returns a JSON string instead. This fouls up the xml parser on the client side.

My question is; is there a way to designate the return type on a particular webmethod in SUDS so that it does not try to run it through the xml parser? I just want the raw JSON response.

like image 631
feathj Avatar asked Oct 11 '11 22:10

feathj


1 Answers

I would use the Python JSON encoder to validate first if it is JSON before feeding it to the XML parser.

try:
    json.loads(json_to_test)
except ValueError:
    print "Invalid json"
like image 116
André Ricardo Avatar answered Sep 18 '22 16:09

André Ricardo