api - How to handle python suds return return body[0].children -


i'm building backend process using python+suds connecting ms navision 2009 r2 web services(soap api).

so far good, here's i've got starters:

from suds.client import client suds.transport.https import windowshttpauthenticated ntlm = windowshttpauthenticated(username='***\\***', password='*******') url = 'http://host:7047/dynamicsnav/ws/company/page/serial_number_information' client = client(url, transport=ntlm) print (client) try:   result = client.service.read(' ', ' ', 'value') except webfault, e:   print e   print (result) 

i'm running scenario following soap reply:

<soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body/> </soap:envelope> 

is causing process throw following error:

traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.7/dist-packages/suds/client.py", line 542, in __call__ return client.invoke(args, kwargs) file "/usr/lib/python2.7/dist-packages/suds/client.py", line 602, in invoke result = self.send(soapenv) file "/usr/lib/python2.7/dist-packages/suds/client.py", line 647, in send result = self.succeeded(binding, reply.message) file "/usr/lib/python2.7/dist-packages/suds/client.py", line 684, in succeeded reply, result = binding.get_reply(self.method, reply) file "/usr/lib/python2.7/dist-packages/suds/bindings/binding.py", line 153, in get_reply nodes = self.replycontent(method, soapbody) file "/usr/lib/python2.7/dist-packages/suds/bindings/document.py", line 75, in replycontent return body[0].children attributeerror: 'nonetype' object has no attribute 'children' 

i've tried

if not result:   foo 

and

if not key in result:   foo 

i'm not sure how trap , move on error. appreciated.

resolved it. added second "except"

try:   result = client.service.read(' ', ' ', 'value') except webfault, e:   print e except attributeerror, e:   print e 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -