如何遵守 WSDL 中定义的策略 [英] How to comply with policy defined in WSDL

查看:29
本文介绍了如何遵守 WSDL 中定义的策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Zeep

有一个公开可用的 WSDL 和一个 测试 WSDL(有自签名证书)

There is a publicly available WSDL, and a testing WSDL (has a self-signed cert)

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

My code to test (from test site) is:

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>

网络服务的所有者向我提供了用户名和密码,所以我知道我需要提供这些信息,但肯定还有其他东西我遗漏了.我认为这与 WSDL 中定义的策略有关,但 Web 服务在文档方面没有提供任何内容.

I was provided a username and password from the owners of the web service, so I know I'll need to provide that, but there must be something else I'm missing. I believe it has to do with the policy defined in the WSDL, but the web service doesn't provide anything in terms of documentation.

我是 SOAP 新手,但 WSDL 中是否有足够的内容让我确定他们需要遵守政策的内容?

I'm new to SOAP, but is there enough in the WSDL for me to figure what they need to comply with policy?

我是否可以使用 Zeep 来完成所有政策?

Will I be able to use Zeep to fulfill all the policies?

我需要网络服务维护人员提供更多信息吗?

Do I need more info from those maintaining the web service?

推荐答案

并不是直接回答您的问题,但是当我必须提出肥皂请求时,我喜欢通过使用 soapui.

Not that it's a direct answer to your question, but when I have to make a soap request I like to familiarize myself with the API by using soapui.

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

Once you provide a WSDL for soapui, it will automatically generate all of the required parameters for a proper request. By doing so, you can validate that the error you're receiving is because of a system policy and not because of zeep.

这篇关于如何遵守 WSDL 中定义的策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆