2023-06-13

React Soap Call - ADDING EXTRA OPERATION

Hi I used following example to make successful react soap service and client

https://github.com/officer-rosmarino/node-soap-example

I tried to add in a second service/operation ie add a message joiner function as well as a message splitter but I am failing to understand the intricacies

I can get change the service by changing MessageSplitter to MessageJoiner but cant publish service object to allow multiple operations ie: call MessageSplitter or MessageJoiner from Client from same service

I created separate elements in wsdl as below and tried various ways

I also tried combining operations under 1 port type in below but that produces errors - the below works but runs the same function when i call each service in turn in client ie it runs MessageSplitter twice and never runs MessageJoiner unless i change service object

<?xml version="1.0" encoding="UTF-8"?>
<!-- <definitions> must be the root of the WSDL document -->
<wsdl:definitions targetNamespace="http://tempuri.org/" 
  xmlns:s="http://www.w3.org/2001/XMLSchema" 
  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
  xmlns:soap14="http://schemas.xmlsoap.org/wsdl/soap12/" 
  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
  xmlns:tns="http://tempuri.org/" 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:soap1="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <!-- WSDL TYPES: definition of the data types that are used in the web service -->
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
      <s:element name="MessageSplitterRequest">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="message" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="splitter" type="s:string"/>
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="MessageSplitterResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="unbounded" name="result" type="s:string"/>
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
  </wsdl:types>
  <!-- MESSAGES: defines the data being exchanged between the service and client -->
  <wsdl:message name="MessageSplitterSoapIn">
    <wsdl:part name="parameters" element="tns:MessageSplitterRequest"/>
  </wsdl:message>
  <wsdl:message name="MessageSplitterSoapOut">
    <wsdl:part name="parameters" element="tns:MessageSplitterResponse"/>
  </wsdl:message>
  <!-- PORT TYPES: defines the complete communication operation (one way/round trip) -->
  <wsdl:portType name="MessageSplitterSoapPort">
    <!-- The operation name must be the same as the one specified in the service object -->
    <wsdl:operation name="MessageSplitter">
      <wsdl:input message="tns:MessageSplitterSoapIn"/>
      <wsdl:output message="tns:MessageSplitterSoapOut"/>
    </wsdl:operation>
    
  </wsdl:portType>
  <wsdl:portType name="MessageSplitterSoapPort1">
    <!-- The operation name must be the same as the one specified in the service object -->
  
    <wsdl:operation name="MessageJoiner">
      <wsdl:input message="tns:MessageSplitterSoapIn"/>
      <wsdl:output message="tns:MessageSplitterSoapOut"/>
    </wsdl:operation>
  </wsdl:portType>
 
  <!-- BINDING: provides details on how a portType operation will actually be transmitted -->
  <wsdl:binding name="MessageSplitterServiceSoapBinding" type="tns:MessageSplitterSoapPort">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="MessageSplitter">
      <soap:operation soapAction="MessageSplitter" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
   <wsdl:binding name="MessageSplitterServiceSoap1Binding" type="tns:MessageSplitterSoapPort1">
    <soap1:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="MessageJoiner">
      <soap1:operation soapAction="MessageJoiner" style="document"/>
      <wsdl:input>
        <soap1:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap1:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="MessageSplitterServiceSoap12Binding" type="tns:MessageSplitterSoapPort">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="MessageSplitter">
      <soap12:operation soapAction="MessageSplitter" style="document"/>
      <wsdl:input>
        <soap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
   <wsdl:binding name="MessageSplitterServiceSoap14Binding" type="tns:MessageSplitterSoapPort1">
    <soap14:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="MessageJoiner">
      <soap14:operation soapAction="MessageJoiner" style="document"/>
      <wsdl:input>
        <soap14:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap14:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <!-- SERVICE:  -->
  <wsdl:service name="MessageSplitterService">
    <wsdl:port name="MessageSplitterServiceSoapPort" binding="tns:MessageSplitterServiceSoapBinding">
      <soap:address location="http://localhost:8000/wsdl"/>
    </wsdl:port>
     <wsdl:port name="MessageSplitterServiceSoap1Port" binding="tns:MessageSplitterServiceSoap1jBinding">
      <soap1:address location="http://localhost:8000/wsdl"/>
    </wsdl:port>
    <wsdl:port name="MessageSplitterServiceSoap12Port" binding="tns:MessageSplitterServiceSoap12Binding">
      <soap12:address location="http://localhost:8000/wsdl"/>
    </wsdl:port>
    <wsdl:port name="MessageSplitterServiceSoap14Port" binding="tns:MessageSplitterServiceSoap14Binding">
      <soap14:address location="http://localhost:8000/wsdl"/>
    </wsdl:port>
  </wsdl:service>
  

</wsdl:definitions>
  MessageSplitterService: {
    MessageSplitterServiceSoapPort: {
      MessageSplitter: splitter_function,
      //MessageSplitter: joiner_function,
    },
    MessageSplitterServiceSoap12Port: {
      MessageJoiner: joiner_function,
      // MessageSplitter: joiner_function,
    },
    MessageSplitterServiceSoap1Port: {
      MessageJoiner: joiner_function,
      //MessageSplitter: joiner_function,
    },
    MessageSplitterServiceSoap14Port: {
      MessageJoiner: joiner_function,
      // MessageSplitter: joiner_function,
    },
  },
};

Do I need to create completely different service objects and publish them on separate ports or a wsdl for each operation thanks Advice appreciated!!!

update: i merged all into one service but still cannot get to work only splitter action will work

<?xml version="1.0" encoding="UTF-8"?>
<!-- <definitions> must be the root of the WSDL document -->
<wsdl:definitions targetNamespace="http://tempuri.org/" 
  xmlns:s="http://www.w3.org/2001/XMLSchema" 
  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
  xmlns:tns="http://tempuri.org/" 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <!-- WSDL TYPES: definition of the data types that are used in the web service -->
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
      <s:element name="MessageSplitterRequest">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="message" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="splitter" type="s:string"/>
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="MessageSplitterResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="unbounded" name="result" type="s:string"/>
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="MessageJoinerRequest">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="message" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="joiner" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="splitter" type="s:string"/>
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="MessageJoinerResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="unbounded" name="result" type="s:string"/>
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
  </wsdl:types>
  <!-- MESSAGES: defines the data being exchanged between the service and client -->
  <wsdl:message name="MessageSplitterSoapIn">
    <wsdl:part name="parameters" element="tns:MessageSplitterRequest"/>
  </wsdl:message>
  <wsdl:message name="MessageSplitterSoapOut">
    <wsdl:part name="parameters" element="tns:MessageSplitterResponse"/>
  </wsdl:message>
   <wsdl:message name="MessageJoinerSoapIn">
    <wsdl:part name="parameters" element="tns:MessageJoinerRequest"/>
  </wsdl:message>
  <wsdl:message name="MessageJoinerSoapOut">
    <wsdl:part name="parameters" element="tns:MessageJoinerResponse"/>
  </wsdl:message>
  <!-- PORT TYPES: defines the complete communication operation (one way/round trip) -->
  <wsdl:portType name="MessageSplitterSoapPort">
    <!-- The operation name must be the same as the one specified in the service object -->
    <wsdl:operation name="MessageSplitter">
      <wsdl:input message="tns:MessageSplitterSoapIn"/>
      <wsdl:output message="tns:MessageSplitterSoapOut"/>
    </wsdl:operation>
   
  
    <!-- The operation name must be the same as the one specified in the service object -->
    
    <wsdl:operation name="MessageJoiner">
      <wsdl:input message="tns:MessageJoinerSoapIn"/>
      <wsdl:output message="tns:MessageJoinerSoapOut"/>
    </wsdl:operation>
  </wsdl:portType>
 
  <!-- BINDING: provides details on how a portType operation will actually be transmitted -->
  <wsdl:binding name="MessageSplitterServiceSoapBinding" type="tns:MessageSplitterSoapPort">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="MessageSplitter">
      <soap:operation soapAction="MessageSplitter" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
     <wsdl:operation name="MessageJoiner">
      <soap:operation soapAction="MessageJoiner" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  
  <wsdl:binding name="MessageSplitterServiceSoap12Binding" type="tns:MessageSplitterSoapPort">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="MessageSplitter">
      <soap12:operation soapAction="MessageSplitter" style="document"/>
      <wsdl:input>
        <soap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="MessageJoiner">
      <soap12:operation soapAction="MessageJoiner" style="document"/>
      <wsdl:input>
        <soap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
    
  <!-- SERVICE:  -->
  <wsdl:service name="MessageSplitterService">
    <wsdl:port name="MessageSplitterServiceSoapPort" binding="tns:MessageSplitterServiceSoapBinding">
      <soap:address location="http://localhost:8000/wsdl"/>
    </wsdl:port>
   
    <wsdl:port name="MessageSplitterServiceSoap12Port" binding="tns:MessageSplitterServiceSoap12Binding">
      <soap12:address location="http://localhost:8000/wsdl"/>
    </wsdl:port>
   
  </wsdl:service>
  

</wsdl:definitions>


No comments:

Post a Comment