使用 Spyne,尝试将生成的多个命名空间压缩为 SOAP 请求中的单个命名空间



我有以下SOAPUI使用Spyne请求的ComplexModel方法生成的SOAP请求。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ava="Namespace-1"
xmlns:book="spyne.example.django.models">
<soapenv:Header/>
<soapenv:Body>
<ava:GetChangesRequest>
<book:RequestIds>String1</book:RequestIds>
<book:From>2019-09-22</book:From>
<!--Optional:-->
<book:StartIndex>0</book:StartIndex>
</ava:GetChangesRequest>
</soapenv:Body>
</soapenv:Envelope>

请求的复杂模型如下。

class GetChangesRequest(ComplexModel):
RequestIds = Unicode.customize(min_occurs=1)
From = Date.customize(min_occurs=1)
StartIndex = Integer.customize(default=0, min_occurs=0)

@rpc定义是

@rpc(
GetChangesRequest,
_returns=GetChangesResponse,
_in_message_name='GetChangesRequest',
_out_message_name='GetChangesResponse',
_body_style='bare',
)

现在,我希望避免在请求中使用这些多个命名空间。

关注此 Stackoverflow 帖子 从 Spyne 响应变量中删除命名空间

并且能够按照我想要的方式管理自定义响应。但是无法通过 Spyne 为肥皂请求找到任何这样的方法。

此处的任何指针都会有所帮助。

您需要使传递给应用程序的tns参数与GetChangesRequest命名空间值相同。

class GetChangesRequest(ComplexModel):
__namespace__ = 'Namespace-1'
RequestIds = Unicode.customize(min_occurs=1)
From = Date.customize(min_occurs=1)
StartIndex = Integer.customize(default=0, min_occurs=0)

最新更新