【问题标题】:How to comply with policy defined in WSDL如何遵守 WSDL 中定义的策略
【发布时间】:2017-06-02 13:58:35
【问题描述】:

我正在尝试使用 Zeep 访问 SOAP Web 服务

有一个公开的WSDL 和一个testing WSDL(有一个自签名证书)

我要测试的代码(来自测试站点)是:

from requests import Session
from zeep import Client
from zeep.transports import Transport
from zeep.wsse.username import UsernameToken
import xml.dom.minidom

WS_USER_NAME = '<username>'
WS_PASSWORD = '<password>'
WS_WSDL = 'https://pre.ipddb.org/WS/Services/IpdDownloadService.svc?wsdl'

session = Session()
session.verify = False
transport = Transport(session=session,
                      operation_timeout=10)
client = Client(wsdl=WS_WSDL,
                wsse=UsernameToken(WS_USER_NAME, WS_PASSWORD),
                transport=transport)

with client.options(raw_response=True):

    response = client.service.Search(strNames='Rick Astley')
    xml = xml.dom.minidom.parseString(response._content)
    print xml.toprettyxml()

我的回复是:

<?xml version="1.0" ?>
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
        <a:RelatesTo>urn:uuid:5ffbeb15-913b-41ec-a2ef-556c131c07eb</a:RelatesTo>
    </s:Header>
    <s:Body>
        <s:Fault>
            <s:Code>
                <s:Value>s:Sender</s:Value>
                <s:Subcode>
                    <s:Value xmlns:a="http://schemas.xmlsoap.org/ws/2005/02/sc">a:BadContextToken</s:Value>
                </s:Subcode>
            </s:Code>
            <s:Reason>
                <s:Text xml:lang="es-ES">The message could not be processed. This is most likely because the action 'https://www.ipddb.org/ws/IpdDownloadService/Search' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.</s:Text>
            </s:Reason>
        </s:Fault>
    </s:Body>
</s:Envelope>

Web 服务的所有者向我提供了用户名和密码,因此我知道我需要提供该用户名和密码,但我肯定还缺少其他东西。我认为这与 WSDL 中定义的策略有关,但 Web 服务没有提供任何文档方面的内容。

我是 SOAP 新手,但是 WSDL 中有足够的内容让我了解他们需要什么来遵守政策吗?

我可以使用Zeep 来履行所有政策吗?

我需要从维护网络服务的人员那里获得更多信息吗?

【问题讨论】:

    标签: python wcf soap wsdl zeep


    【解决方案1】:

    不是直接回答您的问题,而是当我必须提出一个肥皂请求时,我喜欢使用 soapui 熟悉 API。

    一旦您为soapui 提供了一个WSDL,它将自动为一个正确的请求生成所有必需的参数。通过这样做,您可以验证您收到的错误是因为系统策略而不是因为 zeep。

    【讨论】:

    • 我实际上是从SoapUI 开始的,并得到了同样的错误。我的最终目标是使用 Zeep,但即使使用 SoapUI 我也会收到此错误
    猜你喜欢
    • 2011-09-10
    • 1970-01-01
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多