How to merge two wsdl in a wsdl file?

3.7k views Asked by At

I created a proxy in WSO2 ESB, and used two different endpoints in it. Then I want to publish a common wsdl. I have two wsdl adresses from two different web services.

1- http://localhost:12080/SRV-CSB-MOCK/CsbService?wsdl

<?xml version="1.0" ?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://csb.sgrs.ayesas.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="CsbService" targetNamespace="http://csb.sgrs.ayesas.com/">
  <wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://csb.sgrs.ayesas.com/" elementFormDefault="unqualified" targetNamespace="http://csb.sgrs.ayesas.com/" version="1.0">

  <xs:element name="carpma" type="tns:carpma"></xs:element>

  <xs:element name="carpmaResponse" type="tns:carpmaResponse"></xs:element>

  <xs:complexType name="carpma">
    <xs:sequence>
      <xs:element name="ilk" type="xs:int"></xs:element>
      <xs:element name="son" type="xs:int"></xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="carpmaResponse">
    <xs:sequence>
      <xs:element name="return" type="xs:int"></xs:element>
    </xs:sequence>
  </xs:complexType>

</xs:schema>
  </wsdl:types>
  <wsdl:message name="carpma">
    <wsdl:part element="tns:carpma" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="carpmaResponse">
    <wsdl:part element="tns:carpmaResponse" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="CsbService">
    <wsdl:operation name="carpma">
      <wsdl:input message="tns:carpma" name="carpma">
    </wsdl:input>
      <wsdl:output message="tns:carpmaResponse" name="carpmaResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="CsbServiceSoapBinding" type="tns:CsbService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
    <wsdl:operation name="carpma">
      <soap:operation soapAction="carpma" style="document"></soap:operation>
      <wsdl:input name="carpma">
        <soap:body use="literal"></soap:body>
      </wsdl:input>
      <wsdl:output name="carpmaResponse">
        <soap:body use="literal"></soap:body>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="CsbService">
    <wsdl:port binding="tns:CsbServiceSoapBinding" name="CsbServicePort">
      <soap:address location="http://localhost:12080/SRV-CSB-MOCK/CsbService"></soap:address>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

2- http://localhost:12080/SRV_DBS_MOCK/MockGTHBService/MockGTHBService?wsdl

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://gthb.dbs.ayesas.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://gthb.dbs.ayesas.com/">
   <wsdl:types>
      <xsd:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://gthb.dbs.ayesas.com/" version="1.0">
         <xsd:element name="add" type="tns:add"></xsd:element>
         <xsd:element name="addResponse" type="tns:addResponse"></xsd:element>
         <xsd:complexType name="add">
            <xsd:sequence>
               <xsd:element name="x" type="xsd:int"></xsd:element>
               <xsd:element name="y" type="xsd:int"></xsd:element>
            </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="addResponse">
            <xsd:sequence>
               <xsd:element name="return" type="xsd:int"></xsd:element>
            </xsd:sequence>
         </xsd:complexType>
      </xsd:schema>
   </wsdl:types>
   <wsdl:message name="add">
      <wsdl:part name="parameters" element="tns:add"></wsdl:part>
   </wsdl:message>
   <wsdl:message name="addResponse">
      <wsdl:part name="parameters" element="tns:addResponse"></wsdl:part>
   </wsdl:message>
   <wsdl:portType name="GTHBProxyPortType">
      <wsdl:operation name="add">
         <wsdl:input message="tns:add" wsaw:Action="add"></wsdl:input>
         <wsdl:output message="tns:addResponse" wsaw:Action="http://gthb.dbs.ayesas.com/MockGTHBService/addResponse"></wsdl:output>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="GTHBProxySoap11Binding" type="tns:GTHBProxyPortType">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
      <wsdl:operation name="add">
         <soap:operation soapAction="add" style="document"></soap:operation>
         <wsdl:input>
            <soap:body use="literal"></soap:body>
         </wsdl:input>
         <wsdl:output>
            <soap:body use="literal"></soap:body>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:binding name="GTHBProxySoap12Binding" type="tns:GTHBProxyPortType">
      <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap12:binding>
      <wsdl:operation name="add">
         <soap12:operation soapAction="add" style="document"></soap12:operation>
         <wsdl:input>
            <soap12:body use="literal"></soap12:body>
         </wsdl:input>
         <wsdl:output>
            <soap12:body use="literal"></soap12:body>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:binding name="GTHBProxyHttpBinding" type="tns:GTHBProxyPortType">
      <http:binding verb="POST"></http:binding>
      <wsdl:operation name="add">
         <http:operation location="add"></http:operation>
         <wsdl:input>
            <mime:content type="text/xml" part="parameters"></mime:content>
         </wsdl:input>
         <wsdl:output>
            <mime:content type="text/xml" part="parameters"></mime:content>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="GTHBProxy">
      <wsdl:port name="GTHBProxyHttpSoap11Endpoint" binding="tns:GTHBProxySoap11Binding">
         <soap:address location="http://localhost.localdomain:8280/services/GTHBProxy.GTHBProxyHttpSoap11Endpoint"></soap:address>
      </wsdl:port>
      <wsdl:port name="GTHBProxyHttpsSoap11Endpoint" binding="tns:GTHBProxySoap11Binding">
         <soap:address location="https://localhost.localdomain:8243/services/GTHBProxy.GTHBProxyHttpsSoap11Endpoint"></soap:address>
      </wsdl:port>
      <wsdl:port name="GTHBProxyHttpsSoap12Endpoint" binding="tns:GTHBProxySoap12Binding">
         <soap12:address location="https://localhost.localdomain:8243/services/GTHBProxy.GTHBProxyHttpsSoap12Endpoint"></soap12:address>
      </wsdl:port>
      <wsdl:port name="GTHBProxyHttpSoap12Endpoint" binding="tns:GTHBProxySoap12Binding">
         <soap12:address location="http://localhost.localdomain:8280/services/GTHBProxy.GTHBProxyHttpSoap12Endpoint"></soap12:address>
      </wsdl:port>
      <wsdl:port name="GTHBProxyHttpsEndpoint" binding="tns:GTHBProxyHttpBinding">
         <http:address location="https://localhost.localdomain:8243/services/GTHBProxy.GTHBProxyHttpsEndpoint"></http:address>
      </wsdl:port>
      <wsdl:port name="GTHBProxyHttpEndpoint" binding="tns:GTHBProxyHttpBinding">
         <http:address location="http://localhost.localdomain:8280/services/GTHBProxy.GTHBProxyHttpEndpoint"></http:address>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>

I want to merge them in a wsdl file. I added the schemas and methods of second wsdl to first wsdl. But I cannot change targetNamespace="http://csb.sgrs.ayesas.com/" in definitions. So I can't access another methods in second wsdl.

1

There are 1 answers

0
Scott On

Here is a similar questions on StackOverflow that might be of assistance:

Multiple wsdl and xsd files... into a single wsdl

With WsO2 At times it's easier to have two separate endpoints and then create a service that will call both of them and then blend the two results together using an XSLT transformation, or whatever the correct action is for your business use case.

But when you need to have one service that calls two different endpoints, you have the option of creating a WSDL that represents both endpoints by creating a namespace that can work for both.

If you are manually creating a WSDL consider these points:

Ensure that the target namespace of the two WSDL files is the same. If it is not, you will need to update the namespace in one of the files to match the other. IE: Both calls need to have a unique name.

Check for any duplicate element or type definitions in the two WSDL files and remove them.

Check for any naming conflicts between elements, types, and operations in the two WSDL files and resolve them.

Ensure that all imported and included files in the two WSDL files are also merged and their references are updated accordingly.

Validate the merged WSDL file to ensure that it is syntactically and semantically correct.

Test the merged WSDL file with a SOAP client to ensure that it works as expected.