【问题标题】:When hitting SOAP Request using zeep module then getting execption "The given SOAPAction None does not match an operation."使用 zeep 模块点击 SOAP 请求时,出现异常“给定的 SOAPAction None 与操作不匹配”。
【发布时间】:2019-11-06 09:11:18
【问题描述】:

我正在使用 Python 中的 Zeep 模块使用 WS-Security #PAsswordDigest 执行 SOAP 网络服务。但是当点击请求时,就会出现“给定的 SOAPAction None 与操作不匹配”。

    from zeep.wsse.username import UsernameToken
    from zeep import Client , Settings , xsd


    username = 'username'
    password = 'password'

    WSDL_URL = 'http://0.0.0.0:0000/wsdl/sdpService.wsdl'


    settings = Settings(strict=False, xml_huge_tree=True)
    token = UsernameToken(username, password, use_digest=True)

    client = Client(wsdl=WSDL_URL, wsse=token, service_name="UserService", port_name="UserServiceSOAP", settings=settings)

    header_value = {
        "SOAPAction" : ""
    }

    with client.settings(raw_response=True):
        response = client.service.Authenticate()

    print(response.text)

点击上面的请求得到错误

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>The given SOAPAction None does not match an operation.</faultstring></soap:Fault></soap:Body></soap:Envelope>

【问题讨论】:

  • 您没有在任何地方使用“header_value”,您可以删除它并尝试吗?

标签: python soap zeep


【解决方案1】:

我使用 python >> zeep >> Plugin >> egress 得到了解决方案。

def egress(self, envelope, http_headers, operation, binding_options):
        self.log.info("Request XML to SERVER :: \n"+parseString(etree.tostring(envelope)).toprettyxml()+"\n")
        http_headers = {
            'Content-Type': 'text/xml; charset=utf-8',
            'SOAPAction': b'""'
        }
        return envelope, http_headers

我可以将“SOAPAction”键值从“None”修改为“”

【讨论】:

    【解决方案2】:

    这是 Zeep 中的一个错误。

    我刚刚遇到了同样的问题,并创建了一个带有 fix 的 PR

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 1970-01-01
      相关资源
      最近更新 更多