首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Apache Camel调用CXF CXF服务

通过Apache Camel调用CXF CXF服务
EN

Stack Overflow用户
提问于 2012-04-25 00:19:14
回答 2查看 15.5K关注 0票数 2

我正在尝试集成Apache CXF和Apache Camel。camel配置:

代码语言:javascript
复制
<cxf:cxfEndpoint id="authTest"
        address="/cxfAuth"
        serviceClass="com.test.AuthService" >
        <cxf:properties>
            <entry key="dataFormat" value="POJO" />
            <entry key="setDefaultBus" value="true" />
        </cxf:properties>
    </cxf:cxfEndpoint>

     <camel:camelContext trace="true">
        <camel:route>
            <camel:from uri="cxf:bean:authTest" />
            <camel:to uri="bean:routeExitResponseProcessor"/>
        </camel:route>
    </camel:camelContext>

现在,为了调用web服务上的特定操作,我使用以下代码:

代码语言:javascript
复制
<camel:route>
            <camel:from uri="direct:startAuthTest"/>
            <camel:setHeader headerName="getEmployee"> 
                <camel:constant>gid</camel:constant> 
            </camel:setHeader> 
            <camel:to uri="cxf:bean:authTest" />
            <camel:log message=">>> data is : ${body}"/>
            <camel:to uri="bean:routeExitResponseProcessor"/>
        </camel:route>

但在包含上述配置后,我在服务器控制台上获得了WARN ServletController:149 - Can't find the the request for http://localhost:8080/CXFService/services/cxfAuth's Observer,而我的and服务在浏览器上找不到。

请帮帮忙。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-04-25 01:43:49

您可以调用以下代码来获取CXF操作的名称为called...see http://camel.apache.org/cxf.html,以了解更多详细信息

代码语言:javascript
复制
String operation = (String)in.getHeader(CxfConstants.OPERATION_NAME);

此外,请参阅此单元测试以了解用法示例...

http://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java

票数 2
EN

Stack Overflow用户

发布于 2014-12-05 21:56:49

在CXF端点

代码语言:javascript
复制
    <cxf:cxfEndpoint id="yourServiceCall"
    address="http://localhost:8181/yourservice/services/yourserviceport"
    wsdlURL="wsdl/yourwsdl.wsdl" xmlns:ns="http://service.your.com"
    endpointName="ns:YourServicePort" serviceName="ns:yourService"
    serviceClass="com.service.YourServicePortType">

和在Camel端点

代码语言:javascript
复制
   camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring">
   <camel:dataFormats>
        <camel:jaxb contextPath="com.your.service" id="jaxb" />
    </camel:dataFormats>

    <route id="route1">
        <from uri="cxf:bean:yourServiceCall?dataFormat=PAYLOAD" />
        <camel:unmarshal ref="jaxb" />
        <log message="log: Called from cxf endpoint" />
        <!-- Your Logic -->
        <camel:process ref="ExitResponseProcessor"/>
        <camel:marshal ref="jaxb" />
    </camel:route>

基于Himanshu Yadav评论:更新

代码语言:javascript
复制
 <camel:choice>
 <camel:when>
 <camel:simple>${body} is com.your.service.YourRequest</camel:simple>
 <!-- Your Logic or call any bean method with <camel:bean ref="YourBean " method="YourMethod" /      /> -->
 </camel:when>
 <camel:when> </camel:when>
 <camel:otherwise> </camel:otherwise>
 </camel:choice
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10301895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档