java - 如何在camel配置中定义公共(public)路由体?

标签 java web-services soap apache-camel cxf

我在 Camel 配置中有两条路线

路线1

    <route>
        <from uri="cxf:bean:soapProxy1?dataFormat=PAYLOAD" />
        <setHeader headerName="CamelHttpMethod">
          <constant>POST</constant>
        </setHeader>
        <setHeader headerName="Contents-type">
          <constant>application/octet-stream</constant>
        </setHeader>
        <setHeader headerName="SOAPAction">
          <constant>vc</constant>
        </setHeader>
        <setHeader headerName="Accept">
          <constant>application/xml</constant>
        </setHeader>

        <to uri="bean:samlWsBean" />            

        <choice>
            <when>
                <simple>${in.header.isvalid} contains "true"</simple>
                <to uri="cxf:bean:backendService?dataFormat=PAYLOAD"/>
            </when>
            <otherwise>     
                <to uri="velocity:file:///path/samlerrorresponse.vm"/>
            </otherwise>
        </choice>
    </route>

路线2

    <route>
        <from uri="cxf:bean:soapProxy2?dataFormat=PAYLOAD" />
        <setHeader headerName="CamelHttpMethod">
          <constant>POST</constant>
        </setHeader>
        <setHeader headerName="Contents-type">
          <constant>application/octet-stream</constant>
        </setHeader>
        <setHeader headerName="SOAPAction">
          <constant>vc</constant>
        </setHeader>
        <setHeader headerName="Accept">
          <constant>application/xml</constant>
        </setHeader>

        <to uri="bean:samlWsBean" />            

        <choice>
            <when>
                <simple>${in.header.isvalid} contains "true"</simple>
                <to uri="cxf:bean:backendService?dataFormat=PAYLOAD"/>
            </when>
            <otherwise>     
                <to uri="velocity:file:///path/samlerrorresponse.vm"/>
            </otherwise>
        </choice>
    </route>

两条路线仅存在一根线路差异。

有人有这个

<from uri="cxf:bean:soapProxy1?dataFormat=PAYLOAD" />

另一个有这个

<from uri="cxf:bean:soapProxy2?dataFormat=PAYLOAD" />

那么我可以将通用主体放在配置中的其他位置并在两个路由中引用吗?

最佳答案

当没有人回答我的问题时,我开始再次在线搜索,我找到了这样的解决方案

<camel:route id="myCommonPartOfFlow">
  <camel:from uri="direct-vm:common-in"/>
  [common part]
</camel:route>

然后你可以像这样调用

<camel:to uri="direct-vm:common-in/>

有关更多帮助,请参阅 thisthis ,希望这可以帮助其他人。

关于java - 如何在camel配置中定义公共(public)路由体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30754300/

相关文章:

linux - debian 上的 OpenJDK 崩溃日志

WCF、Web 服务或 ADO.NET 数据服务 : What shall I use?

java - 容器中的 JAX-WS 实现与单独的标准应用程序之间的区别

c# - 来自 AXIS 的 SOAP 操作错误

Java使用正则表达式提取文件名

java - 使用 Maven 生成 JAR

java - Android 的 SOAP 1.1、SOAP 1.2、HTTP GET 和 HTTP POST 方法有什么区别?

java - CacheLoader 多次加载相同的键

java - 在java中完全覆盖克隆对象

PHP 和 SoapClient : parameters missing from SOAP request