【问题标题】:Using Camel with tomcat, cxf and jax-ws/rs将 Camel 与 tomcat、cxf 和 jax-ws/rs 一起使用
【发布时间】:2012-11-28 18:56:48
【问题描述】:

我想我需要这样的东西:http://camel.apache.org/cxf-tomcat-example.html

我有一个带有 jax-ws 注释的 web 服务类,我想使用这个类来处理请求并产生响应,而不是使用自定义处理器。 像这样:from(cxf ws endpoit).to(my webservice implementation)

这可能吗?我可以将我的消息路由到正确的 java 方法吗? 这与我可以使用cxf 和jax-ws 完全相同,但我也想使用骆驼。 我想使用代码优先的方法(生成的 WSDL)。

【问题讨论】:

    标签: tomcat jax-ws cxf jax-rs apache-camel


    【解决方案1】:

    我可以将我的消息路由到正确的 java 方法吗?

    如果你的意思是你手动创建的bean的具体方法,那么是的。

    例如:

    创建自定义 bean:

    public class CustomProcessor {
    
        public void processSomething(Exchange exchange) {
            Something smth = exchange.getIn().getBody(Something.class); //Your message's body              
        }
    
    }
    

    使用Spring 创建一个类似这样的骆驼配置:

    <bean id="processor" class="your.custom.CustomProcessor"/>
    
    <camel:camelContext trace="true" id="camelContext" >
    
        <camel:route id="camelRoute">
            <camel:from uri="cxf:bean:yourWebServiceListenerEndpoint?dataFormat=POJO&amp;synchronous=true" />
            <camel:choice>
                <camel:when>
                    <camel:simple>${headers.operationName} == 'DoSomething'</camel:simple>
                    <camel:bean ref="processor" method="processSomething"/>
                </camel:when>
            </camel:choice>
            <camel:to uri="cxf:bean:yourWebServiceTargetEndpoint"/>
        </camel:route>
    
    </camel:camelContext>
    

    根据操作名称骆驼将消息路由到相应的处理器。你可以用任何你喜欢的方式在 Camel 中发送你的消息。你只需要想想怎么做。从你的问题来看,这是我能给出的。如果您将其更新为更具体,也许我可以提供更多帮助。

    另请参阅:

    【讨论】:

      猜你喜欢
      • 2011-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 1970-01-01
      • 2011-06-29
      • 2011-12-16
      相关资源
      最近更新 更多