我试图弄清楚如何使用 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] 可能出现在任何元素上,..."