0

I want to invoke a rest service using apache camel. Currently i am using the cxfrs component to configure my endpoint. My route looks like below:

from("cxfrs://http://127.0.0.1:8080/RestServiceApp/?resourceClasses="com.sample.Server.HelloWorld").log("Route Started"); 

My problem is that i want to invoke a method present in the server class (HelloWorld in my case). Can you please tell me how do i call a particular method?

RichaS
  • 219
  • 3
  • 14
  • This user has reported the same question on Camel mailing list - http://camel.465427.n5.nabble.com/RestFul-service-using-camel-td5726656.html – Claus Ibsen Feb 01 '13 at 08:01

1 Answers1

0

Camel doesn't call resource class methods. From the documentation on the Camel web-site http://camel.apache.org/cxfrs.html:

This class is used to configure the JAXRS properties ONLY. The methods will NOT be executed during the routing of messages to the endpoint, the route itself is responsible for ALL processing instead.

You need to write a custom processing logic, for example as following:

<from uri="cxfrs://http://127.0.0.1:8080/RestServiceApp/?resourceClasses="com.sample.Server.HelloWorld">
<choice>
    <when>
        <simple>${header.operationName} == 'operation1'</simple>
        <to uri="direct:operation1" />
    </when>
    <when>
        <simple>${header.operationName} == 'operation2'</simple>
        <to uri="direct:operation2" />
    </when>
    ....
</choice>
Alexander Durnev
  • 341
  • 2
  • 13
  • Thank you for the reply alexander. But i want to invoke a web service hosted on a remote server. According to the apache cxfrs document, if you want to invoke the REST service through camel-cxfrs producer, then you need to put the operation name in the message header. But if I am doing from(rest_service_route).process(new MyProcessor()) , the processor is never invoked. Kindly help me with that. – RichaS Feb 01 '13 at 09:22