Calling CXF webservice through Apache Camel

15,515

you can call the following to get the CXF operation name being called...see http://camel.apache.org/cxf.html for more details

String operation = (String)in.getHeader(CxfConstants.OPERATION_NAME);

also, see this unit test for example usage...

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

Share:
15,515
Himanshu Yadav
Author by

Himanshu Yadav

Big data and distributed systems

Updated on June 04, 2022

Comments

  • Himanshu Yadav
    Himanshu Yadav almost 2 years

    I am trying to integrate Apache CXF with Apache Camel. Configuration for camel:

    <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>
    

    Now to invoke specific operation on web service I am using this:

    <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>
    

    But after including above config I am getting WARN ServletController:149 - Can't find the the request for http://localhost:8080/CXFService/services/cxfAuth's Observer on the server console and my webservice is not found on browser.

    Please help.

  • Himanshu Yadav
    Himanshu Yadav about 12 years
    then based on operation names I have to put a lot of if...else. Is there a clean way to do it?
  • Ben ODay
    Ben ODay about 12 years
    see the unit test example I included, but basically choice() stmts can be used in the route or conditionals in the beans/processors, etc...
  • Himanshu Yadav
    Himanshu Yadav about 12 years
    Is there any way to configure it in the camel config file?
  • Ben ODay
    Ben ODay about 12 years
    sure, just use a <choice><when><header>operationName</header>...see camel.apache.org/content-based-router.html for more details