在元素中包装函数参数complexType

时间:2015-04-29 12:06:48

标签: wsdl spyne

我正在尝试使用Spyne实现现有的Web服务。 我有一个带有两个参数的函数,WSDL应该是这样的:

<wsdl:types>
  <xs:schema targetNamespace="http://example.com/" elementFormDefault="qualified" >
    <s:element name="getData">
      <s:complexType>
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="login" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
        </s:sequence>
      </s:complexType>
    </s:element>
[...]

我的代码包含以下用于此功能的装饰器:

@rpc(String(min_occurs=0, max_occurs=1, nillable=False),
     String(min_occurs=0, max_occurs=1, nillable=False),
     _returns=Unicode)
def getData(self, login, password):
     return 'data'

生成此WSDL:

<wsdl:types>
    <xs:schema elementFormDefault="qualified" targetNamespace="http://example.com/">
        <xs:complexType name="getData">
            <xs:sequence>
                <xs:element minOccurs="0" name="login" type="xs:string" />
                <xs:element minOccurs="0" name="password" type="xs:string" />
            </xs:sequence>
        </xs:complexType>
[...]

因此,代替包含complexType的元素,我只有一个简单的complexType。这种差异会导致与现有实施兼容的客户端出现问题。有没有办法使用Spyne将complexType包装在一个元素中?

1 个答案:

答案 0 :(得分:0)

Spyne的wsdl应该同时包含:

<s:element name="getData" type="tns:getData">

arrayoutofbound

在内部元素中使用complexType相当于将它放在外部并使用这样的正确引用,因此您的解析器应该能够处理这两种形式。

如果你对客户没有任何控制权,因为在这种情况下通常就是这种情况,你别无选择,只能修补Spyne。如果你想走那条路,请加入spyne ml(http://lists.spyne.io/listinfo/people),这样我们就可以聊聊。

相关问题