【问题标题】:Duplicating a same SOAP webservice in Camel在 Camel 中复制相同的 SOAP Web 服务
【发布时间】:2015-07-08 06:53:31
【问题描述】:

系统公开了一个 SOAP Web 服务。我有一个 web 服务的 wsdl 文件。我能够发送请求并从soap ui 获得响应。我想在我部署在 servicemix 中的骆驼路由中复制这个 wsdl SOAP 网络服务,从而使我的 ESB 公开一个与系统的网络服务类似的网络服务。许多系统通过这种方式访问​​此 Web 服务以联系系统。 如何使用系统的 wsdl 文件复制 Web 服务?

【问题讨论】:

  • 所以基本上你想在你的 ESB 中使用这个 webervice 并尝试公开它的所有操作,连接到 ESB 的其他客户端。请附上您的代码或解释到目前为止您尝试过的方法以解决这个问题。
  • 我的试验(仅用于使 ESB 联系人暴露 SOAP Web 服务) - 我使用 pom.xml 创建了一个 maven 项目,其中包含 cxf-codegen-plugin 和提到的系统的 wsdl 路径。在构建我的包时,它会在我的项目中从 wsdl 生成代码。我在蓝图 xml 中为 wsdl 创建了一个 cxf bean,并尝试以 PAYLOAD 格式将输入的工作 soal xml 文件从文件夹发送到 cxf 端点。这只是将请求记录在 servicemix.log 中。我尝试打印响应,但端点没有响应。
  • 您实施了响应吗? WSDL 是没有实现的契约。
  • 现在我的 ESB - 生产者到外部系统 Web 服务工作正常。现在让它成为一种 2 方式,我想在我的 ESB 中公开与现有系统的 web 服务相同的 web 服务。

标签: web-services soap wsdl apache-camel apache-servicemix


【解决方案1】:

要复制由系统公开的webservice,您可以使用http代理路由,基于jetty:

    <route id="ServiceProxy">
        <from uri="jetty:http://0.0.0.0:8186/service/?disableStreamCache=true&amp;matchOnUriPrefix=true&amp;continuationTimeout=900000&amp;httpClient.timeout=120000"/>
        <to uri="jetty:http://{{app-server.host}}:{{app-server.http.port}}/service/?bridgeEndpoint=true&amp;throwExceptionOnFailure=false&amp;continuationTimeout=120000&amp;httpClient.timeout=900000"/>
    </route>

您可以在 JavaDSL 上编写相同的路由。

【讨论】:

    【解决方案2】:

    找到解决方案 - 概念是 cxf-proxying

    拥有系统的 wsdl,创建一个类似的 wsdl,其 Endpoints 根据 localhost 和端口号定义。

    将 wsdl 保存在本地项目中, 在 pom 中提供 wsdl 的路径,通过在 cxf-codegen-plugin 中提及将 wsdl 转换为 java。

    使用本地 wsdl 文件的详细信息创建 cxf 消费者 bean

    <cxf:cxfEndpoint id="consumerProxy" address="http://remote:port/service/"
        serviceClass="com.remote.service.RemoteService" endpointName="c:RemoteService"
        serviceName="c:RemoteService" xmlns:c="http://remote/namespace/">
        <cxf:properties>
            <entry key="dataFormat" value="MESSAGE" />
        </cxf:properties>
    </cxf:cxfEndpoint>
    

    使用远程 wsdl 文件的详细信息创建 cxf 生产者 bean

    <cxf:cxfEndpoint id="producerRemote" address="http://localhost:9001/service/"
        serviceClass="com.remote.service.RemoteService" endpointName="c:RemoteService"
        serviceName="c:RemoteService" xmlns:c="http://remote/namespace/">
        <cxf:properties>
            <entry key="dataFormat" value="MESSAGE" />
        </cxf:properties>
    </cxf:cxfEndpoint>
    

    代理路由如下所示

    来自(cxfEndpoint("consumerProxy")) .to(cxfEndpoint("producerRemote"));

    向 localhost 发送请求将被 cxf 端点 - consumerProxy 消费并发送到 cxf 端点 - producerRemote。 响应以相反的方式发回。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多