如何在wsdl文件中合并两个wsdl



我在WSO2 ESB中创建了一个代理,并在其中使用了两个不同的端点。然后我想发布一个公共wsdl。我有两个来自两个不同web服务的wsdl地址。

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>

我想将它们合并到wsdl文件中。我将第二个wsdl的模式和方法添加到第一个wsdl。但是我不能更改定义中的targetNamespace="http://csb.sgrs.ayesas.com/"。所以我不能访问第二个wsdl.

中的其他方法。

这是一个关于StackOverflow的类似问题,可能会有所帮助:

多个wsdl和xsd文件…到一个wsdl

使用WsO2有时更容易拥有两个独立的端点,然后创建一个服务来调用它们,然后使用XSLT转换将两个结果混合在一起,或者使用任何适合您的业务用例的正确操作。

但是,当您需要一个调用两个不同端点的服务时,您可以通过创建一个可以同时适用于两个端点的名称空间来创建一个代表两个端点的WSDL。

如果您正在手动创建WSDL,请考虑以下几点:

确保两个WSDL文件的目标名称空间相同。如果不是,则需要更新其中一个文件中的名称空间以匹配另一个文件。IE:两个调用都需要有一个唯一的名称。

检查两个WSDL文件中是否有任何重复的元素或类型定义,并删除它们。

检查两个WSDL文件中元素、类型和操作之间的任何命名冲突,并解决它们。

确保两个WSDL文件中所有导入和包含的文件也被合并,并且它们的引用也相应更新。

验证合并的WSDL文件,以确保其语法和语义正确。

用SOAP客户端测试合并的WSDL文件,以确保它按预期工作。

最新更新