我正在使用连接到MS Navision 2009 R2 Web服务(SOAP api)的python + suds构建后端进程。
到目前为止一切都很好,这是我为初学者所做的事情:
from suds.client import Client
from 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)
我遇到了以下SOAP回复的场景:
<Soap:Envelope xmlns:Soap="http://schemas.xmlsoap.org/soap/envelope/">
<Soap:Body/>
</Soap:Envelope>
导致我的进程抛出以下错误:
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'
我已经尝试了
if not result:
foo
和
if not key in result:
foo
我不确定如何陷阱并继续此错误。任何帮助表示赞赏。
答案 0 :(得分:0)
解决了它。添加了第二个“除外”
try:
result = client.service.Read(' ', ' ', 'value')
except WebFault, e:
print e
except AttributeError, e:
print e