我正在尝试使用Zeep来实现SOAP客户端,因为它似乎是目前唯一维护的库:
因此,尝试使用Zeep时,我坚持使用服务器访问WSDL所需的身份验证.
ZSI的这种操作非常简单:
from ZSI.client import Binding
from ZSI.auth import AUTH
b = Binding(url='http://mysite.dom/services/MyWebServices?WSDL')
b.SetAuth(AUTH.httpbasic, 'userid', 'password')
Run Code Online (Sandbox Code Playgroud)
我可以在Zeep的__main__.py中找到类似的东西:
from six.moves.urllib.parse import urlparse
from zeep.cache import InMemoryCache, SqliteCache
from zeep.client import Client
from zeep.transports import Transport
cache = SqliteCache() if args.cache else InMemoryCache()
transport_kwargs = {'cache': cache}
result = urlparse(args.wsdl_file)
if result.username or result.password:
transport_kwargs['http_auth'] = (result.username, result.password)
transport = Transport(**transport_kwargs)
client = Client(args.wsdl_file, transport=transport)
Run Code Online (Sandbox Code Playgroud)
但这在我的情况下不起作用,我收到一个错误:
Exception: HTTPConnectionPool(host='schemas.xmlsoap.org', port=80): Max retries exceeded with url: /soap/encoding/ (Caused by …
Run Code Online (Sandbox Code Playgroud)