0

I'm starting to implement a web service using Spyne. So far the generated WSDL looks good to the consuming client (either the machine client and the human client).

The only thing is they (the human client) have defined a protocol where messages sent back and forth trhrough web servces don't expect a return value (if you are curious, it's because the protocol relies on async calls in the opposite direction to give return feedback after some task has been completed).

So they are asking me to remove the relevant return Message from the WSDL definition. But I don't seem to find a way.

class BusinessTransactionLogSend(ServiceBase):
    __service_name__ = "BusinessTransactionLogSend"
    __namespace__ = "tns"
    __port_types__ = ['IBusinessTransactionLogSend']

    @rpc(TransactionLog,  _body_style="wrapped", 
         _in_variable_names={'parameters': 'Log'}, 
         _args=['Log'],
         _port_type="IBusinessTransactionLogSend",
         _returns=None,
         _out_message_name='LogResponse')
    def Log(ctx, parameters):
        time.sleep(1)

this is the service and the RPC Log. I've tried putting _returns=None but the WSDL still has

<wsdl:types>
  <xs:schema targetNamespace="https://www.zz/" elementFormDefault="qualified">
    <xs:import namespace="tns"/>
    <xs:complexType name="LogResponse"/>
    <xs:complexType name="Log">
   ...
   ...
   <wsdl:message name="LogResponse">
     <wsdl:part name="LogResponse" element="tns:LogResponse"/>
   </wsdl:message>
  ...
   <wsdl:portType name="IBusinessTransactionLogSend">
       <wsdl:operation name="Log" parameterOrder="Log">
           <wsdl:input name="Log" message="tns:Log"/>
           <wsdl:output name="LogResponse" message="tns:LogResponse"/>
       </wsdl:operation>
   </wsdl:portType>
   ...

Their SOAP/WSDL parser is confused by this LogResponse message. Is there any way to skip this or instruct Spyne not to generate Type and Message for a void return value?

I could write a filter (or maybe it's called listener for events), it seems to appear from looking around, but

  1. I haven't found a complete example nor a good documentation
  2. it seems to me better to tell Spyne to do the chore than me

Of course I could try telling my client to just ignore any xxxResponse message in the WSDL, but I am afraid that their terrible SAP-Based client would still complain

Thanks W

zontar
  • 485
  • 7
  • 18

1 Answers1

0

I've found something not yet documented that solves just part of the problem: we can decorate the method with

@rpc(TransactionLog,  _body_style="wrapped",
         _in_variable_names={'parameters': 'Log'},
         _is_async=True,  #<====================== THIS ======
         _args=['Log'],
         _port_type="IBusinessTransactionLogSend",
         _returns=None
         )

This will get rid of the output part in this WSDL fragment

    <wsdl:portType name="IBusinessTransactionLogSend">
        <wsdl:operation name="Log" parameterOrder="Log">
            <wsdl:input name="Log" message="tns:Log"/>
            <wsdl:output name="LogResponse" message="tns:LogResponse"/>
        </wsdl:operation>
    </wsdl:portType>

which now is

    <wsdl:portType name="IBusinessTransactionLogSend">
        <wsdl:operation name="Log" parameterOrder="Log">
            <wsdl:input name="Log" message="tns:Log"/>
        </wsdl:operation>
    </wsdl:portType>

But still the Message and ComplexType LogResponse is still present in WSDL even though nobody will use it.

zontar
  • 485
  • 7
  • 18