How does SOAP WS know the requested operation?

Say my WSDL contains the following:

<message name="modifRequest">
    <part name="siList" element="sn:siListElement"/>
</message>
<message name="modifResponse">
    <part name="siList" element="sn:boolElement"/>
</message>

<portType name="siModificationPortType">
    <operation name="delete">
        <input message="tns:modifRequest" />
        <output message="tns:modifResponse" />
    </operation>
    <operation name="update">
        <input message="tns:modifRequest" />
        <output message="tns:modifResponse" />
    </operation>
</portType>

      

Which generates the following SOAP client message in SoapUI, whether in an update or delete request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"         xmlns:sim="simSchema">
   <soapenv:Header/>
<soapenv:Body>
  <sim:siListElement>
     <!--1 or more repetitions:-->
     <sim:si name="?" desc="?" workspace="workspace">
        <!--Zero or more repetitions:-->
        <sim:bp name="?" value="?" bps="?"/>
     </sim:si>
  </sim:siListElement>

      

So, it seems that the only thing sent over HTTP to WS is siListElement

. But how does WS know the operation the client wants to achieve (here, delete / update)? Especially when the inputs of both operations have the same structure.

+3


source to share


1 answer


WS knows the operation through the SOAPAction

HTTP header. When you create a new SOAP test request in SOAPUI, you need to select an operation and select it, then SOAPUI will automatically set the operation to request the mapping of this operation to the required one SOAPAction

, which it will send as an HTTP header when you run the test request.

This "magic" happens because your WSDL probably also contains information that you are missing in your question that binds wsdl:operation

to soap:operation

. Your WSDL probably has something like:

<binding name="bindingDelete" type="siModificationPortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="delete">
        <soap:operation soapAction="delete"/>
        <input>
            <soap:body use="literal"/>
        </input>
        <output>
            <soap:body use="literal"/>
        </output>
    </operation>
</binding>

<binding name="bindingAdd" type="siModificationPortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="add">
        <soap:operation soapAction="add"/>
        <input>
            <soap:body use="literal"/>
        </input>
        <output>
            <soap:body use="literal"/>
        </output>
    </operation>
</binding>

      

So when you tell SOAPUI that your operation is to remove , SOAPUI sends the SOAPAction

http header with the correct value, for example delete

, instead of specifying add , then the SOAPAction

http header with some value, for example, is add

sent.



You can check what I am saying by executing your request and clicking the tab Raw

on the left side of your SOAPRequest and checking for different values SOAPAction

for your operation types:

enter image description here

Hope it helps,

+6


source







All Articles