我正在尝试使用 zeep 创建一个 python soap 客户端,但是在尝试访问 wsdl 时遇到了一些问题。无论我尝试了多少网络上现有的解决方案,它们都不再有效,或者只是我的情况有点不同。最有希望的是官方 zeep 文档中的解决方案,但它仍然无法正常工作:
from requests import Session
from requests.auth import HTTPBasicAuth # or HTTPDigestAuth, or OAuth1, etc.
from zeep import Client
from zeep.transports import Transport
session = Session()
session.auth = HTTPBasicAuth(user, password)
client = Client('https://url/to/my_wsdl.wsdl',
transport=Transport(session=session))
但我收到一个错误:
File "C:\Python36-32\lib\site-packages\zeep\client.py", line 124, in __init__
self.wsdl = Document(wsdl, self.transport, strict=strict)
File "C:\Python36-32\lib\site-packages\zeep\wsdl\wsdl.py", line 82, in __init__
root_definitions.resolve_imports()
File "C:\Python36-32\lib\site-packages\zeep\wsdl\wsdl.py", line 234, in resolve_imports
binding.resolve(self)
File "C:\Python36-32\lib\site-packages\zeep\wsdl\definitions.py", line 128, in resolve
operation.resolve(definitions)
File "C:\Python36-32\lib\site-packages\zeep\wsdl\bindings\soap.py", line 428, in resolve
self.output.resolve(definitions, self.abstract.output_message)
File "C:\Python36-32\lib\site-packages\zeep\wsdl\messages\soap.py", line 285, in resolve
self.body = self._resolve_body(info['body'], definitions, parts)
File "C:\Python36-32\lib\site-packages\zeep\wsdl\messages\soap.py", line 423, in _resolve_body
element = part.element.clone()
AttributeError: 'NoneType' object has no attribute 'clone'
我错过了什么或做错了什么?我在 Windows 10 上使用 python3.6 32bit。所有软件包都是使用 pip 全新安装的。