问题描述
我正在尝试使用来自外部SOAP API的操作。该API没有文档,因此我大多处于黑暗之中。我收到了一个使用SOAP API的请求,因此我想尝试使用Python进行集成。
我的吉普车:
wsdl = 'https://asp.external.se/apps/api/service.svc?wsdl'
token = Usernametoken('username','password')
client = Client(wsdl=wsdl,wsse=token)
client.service.GetCompanies()
我可以浏览client.services
并查看所有操作,因此我知道WSDL的设置正确。
但是无论我尝试执行什么操作,我都会收到此错误:
故障:无法处理该消息。这很可能是因为操作“ www.external.com/services/apiservice/GetCompanies”不正确,或者消息包含无效或过期的安全上下文令牌,或者是绑定之间不匹配。如果服务由于不活动而中止通道,则安全上下文令牌将无效。为了防止服务中止空闲会话,请过早增加服务端点绑定上的接收超时。
我能想到的一件事是,在SOAP UI中工作的端点不是WSDL的默认端点,我不得不在SOAP UI中手动添加“ / endpoint2”。不知道我是否可以在zeep中做同样的事情。
这是在SOAP UI中工作的原始信封:
POST www.external.com/services/apiservice/endpoint2
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ".../GetCompanies"
Authorization: Basic Zm9hLWFwaTpGXFGUw==
Content-Length: 1030
Host: asp.external.se
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bril="www.external.com/services/apiservice">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:mustUnderstand="1">
<wsse:Usernametoken wsu:Id="Usernametoken-DE48543B99D24B1D1597402523">
<wsse:Username></wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"></wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">arhKkjhdKuO9yGGw==</wsse:Nonce>
<wsu:Created>2020-08-19T09:59:34.025Z</wsu:Created>
</wsse:Usernametoken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<a:GetCompanies />
</soapenv:Body>
</soapenv:Envelope>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)