此代码通常适用于python 2.7,同时在python 3.7上引发此错误
billresponse = self.client.service.process(__inject={'msg': body})
body
是xml的str
,它在生产环境中运行了2年以上,但是一旦我们升级到python 3.7并安装了suds-py3,就会停止运行。
AttributeError: 'NoneType' object has no attribute 'promotePrefixes'
File "./path/to/file.py", line 119, in soap_connect
billresponse = self.client.service.process(__inject={'msg': body})
File "/var/www/html/venv/lib/python3.7/site-packages/suds/client.py", line 559, in __call__
return client.invoke(args, kwargs)
File "/var/www/html/venv/lib/python3.7/site-packages/suds/client.py", line 785, in invoke
return self.send(msg)
File "/var/www/html/venv/lib/python3.7/site-packages/suds/client.py", line 658, in send
result = self.succeeded(binding, reply.message)
File "/var/www/html/venv/lib/python3.7/site-packages/suds/client.py", line 696, in succeeded
reply, result = binding.get_reply(self.method, reply)
File "/var/www/html/venv/lib/python3.7/site-packages/suds/bindings/binding.py", line 150, in get_reply
soapenv.promotePrefixes()
答案 0 :(得分:0)
这可能有很多原因。
其中,如果suds无法解析响应(因为未收到预期的xml),则会引发此错误。
为了确定收到的肥皂水,请启用肥皂水日志:
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('suds.client').setLevel(logging.DEBUG)