问题描述
关于Authentification on DHL-SOAP API with zeep
我尝试使用 derAndre 提供的代码进行身份验证。但对我来说它没有用。
我只是想获取“getVersion”操作,但由于身份验证而失败。
但是如果我使用它,我会得到一个 401。
Server returned response (401) with invalid XML: Invalid XML content received (Space required after the Public Identifier,line 1,column 50). Content: b'\n\n401 Unauthorized\n\nUnauthorized
\nThis server Could not verify that you\nare authorized to access the document\nrequested. Either you supplied the wrong\ncredentials (e.g.,bad password),or your\nbrowser doesn\'t understand how to supply\nthe credentials required.
\n\n'
这是代码,我不明白。
session = Session()
session.auth = HTTPBasicAuth(settings.dhl_SOAP_API_USER,settings.dhl_SOAP_API_PW)
client = Client(settings.dhl_WSDL,transport=Transport(session=session))
# Build Authentification header for API-Endpoint using zeep xsd
header = xsd.Element(
'{http://test.python-zeep.org}Authentification',xsd.ComplexType([
xsd.Element(
'{http://test.python-zeep.org}user',xsd.String()),xsd.Element(
'{http://test.python-zeep.org}signature',])
)
header_value = header(user=settings.dhl_SOAP_API_USER,signature=settings.dhl_SOAP_API_PW)
result = client.service.getVersion('majorRelease:?','minorRelease:?',_soapheaders=[header_value])
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)