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...
Comments
-
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 about 12 yearsthen based on operation names I have to put a lot of if...else. Is there a clean way to do it?
-
Ben ODay about 12 yearssee 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 about 12 yearsIs there any way to configure it in the camel config file?
-
Ben ODay about 12 yearssure, just use a <choice><when><header>operationName</header>...see camel.apache.org/content-based-router.html for more details