0

我试图弄清楚如何使用 spyne 为这种请求构建一个肥皂服务:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:MyService">
<soapenv:Header/>
  <soapenv:Body>
    <urn:test_rpc soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <urn:in0>test</urn:in0>
    </urn:test_rpc>
  </soapenv:Body>
</soapenv:Envelope>

我的测试方法如下所示:

@spyne.srpc(Unicode, _return=Result, _in_variable_names={"input": 'in0'}, _body_style='wrapped')
def test_rpc(input):
  return Result()

当我发送请求时,soap 服务会响应以下 Webfault:

Server raised fault: ':1:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_3_2_1: Element '{urn:MyService}test_rpc', attribute '{http://schemas.xmlsoap.org/soap/envelope/}encodingStyle': The attribute '{http://schemas.xmlsoap.org/soap/envelope/}encodingStyle' is not allowed.' 

如何在不删除 encodingStyle 的情况下解决此问题?简单对象访问协议 (SOAP) 1.1 W3C 说明 ( http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383495 )的第 4.1.1 节指出“此属性 [encodingStyle] 可能出现在任何元素上,..."

4

1 回答 1

0

从 2.11 开始,Spyne 不支持 encodingStyle 属性。

如果你想实现它:

  1. 制作spyne.interface.xml_schema容纳它生成的XSD
  2. 实现一个 api,用于为不同的 encodingStyle 值插入不同的处理器。
  3. 为您需要的 encodingStyle 值实现不同的处理器。

如果你想解决它:

  1. 切换到软验证
  2. ctx.in_object根据事件ctx.in_document中的信息进行编辑'method_call'

您可以访问http://lists.spyne.io/listinfo/people进行进一步讨论。

高温下,

于 2014-07-31T11:46:42.633 回答