Saturday, October 8, 2016

How to assign multiple 'Soap Action' names to same 'Operation' in WSDL?

Recently we had a situation in a web service migration, we faced a situation where we need to route to the same operation in a proxy service from requests with the different soap action names.

This is particularly useful when designing the web service invocation to different web service clients.

Let us see how the WSDL is designed:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/EmployeeService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="EmployeeService" targetNamespace="http://www.example.org/EmployeeService/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://www.example.org/EmployeeService/">
      <xsd:element name="EmployeeInput">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="firstName" type="xsd:string"/>
            <xsd:element name="lastName" type="xsd:string"/>
            <xsd:element name="address" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="EmployeeOutput">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="fullName" type="xsd:string"/>
            <xsd:element name="address" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="EmployeeRequest">
    <wsdl:part element="tns:EmployeeInput" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="EmployeeResponse">
    <wsdl:part element="tns:EmployeeOutput" name="parameters"/>
  </wsdl:message>
  <wsdl:portType name="EmployeeService">
    <wsdl:operation name="GetEmployeeDetails">
      <wsdl:input message="tns:EmployeeRequest"/>
      <wsdl:output message="tns:EmployeeResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="EmployeeServiceBinding" type="tns:EmployeeService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetEmployeeDetails">
      <soap:operation soapAction="GetEmployeeDetailsActionOne"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="GetEmployeeDetails">
      <soap:operation soapAction="GetEmployeeDetailsActionTwo"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

  </wsdl:binding>
  <wsdl:service name="EmployeeService">
    <wsdl:port binding="tns:EmployeeServiceBinding" name="EmployeeServiceBinding">
      <soap:address location="https://localhost:8243/services/EmployeeService.EmployeeServiceHttpsEndpoint"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


From SoapUI, you can see the same operation name pointing to different SoapAction names.


No comments:

Post a Comment