相关疑难解决方法(0)

带有Zeep的Python SOAP客户端 - 身份验证

我正在尝试使用Zeep来实现SOAP客户端,因为它似乎是目前唯一维护的库:

  • ZSI看起来非常好,但其最新版本的pypi日期为2006年
  • suds似乎是一个受欢迎的选择,但是自2011年以来主人没有得到维护,并且那里有很多分叉,但似乎没有"官方"和"近期"足以在大型项目中使用.

因此,尝试使用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)

python authentication soap wsdl

5
推荐指数
3
解决办法
2万
查看次数

标签 统计

authentication ×1

python ×1

soap ×1

wsdl ×1