pythonxmlsoapwsdlspyne

The encodingStyle attribute is not allowed in spyne


I try to figure out how to build a soap service with spyne to this kind of request:

<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>

My Testmethod looks like this:

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

When I send my requests the soap service respond with following 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.' 

How can I fix this without removing the encodingStyle? The section 4.1.1 of the Simple Object Access Protocol (SOAP) 1.1 W3C Note (http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383495) notes that "This attribute[encodingStyle] MAY appear on any element, ..."


Solution

  • As of 2.11, Spyne doesn't support encodingStyle attribute.

    If you want to implement it:

    1. Make XSD generated by spyne.interface.xml_schema accomodate it
    2. Implement an api for plugging different processors for different encodingStyle values.
    3. Implement different processors for the encodingStyle values you need.

    If you want to work around it:

    1. Switch to soft validation
    2. Edit ctx.in_object according to information in ctx.in_document in a 'method_call' event.

    You can chime in at http://lists.spyne.io/listinfo/people for further discussion.

    HTH,