You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2013/02/01 08:35:59 UTC
Re: RestFul service using camel
On Thu, Jan 31, 2013 at 7:04 PM, Richa <rs...@gmail.com> wrote:
> Hi,
> 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://localhost: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?
>
When you use from, then you let Camel expose a REST service. You want
the opposite, to call a REST service on a remote server.
So for that you need to use .to instead.
So you need to consider when to invoke this REST service, what
triggers that call?
You can use a timer to call it at every X period
from timer
to cxfrs
Or you can also just invoke it from java code using a ProducerTemplate
http://camel.apache.org/producertemplate.html
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: RestFul service using camel
Posted by vjboston <vj...@gmail.com>.
Hi All,
I am trying to achieve the same thing.Invoking a remote restful service.But
the response of the service is Null.
SO the body keeps comign as null.
Can somebody please help me with sample code ?
--
View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5740603.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: RestFul service using camel
Posted by Sergey Beryozkin <sb...@gmail.com>.
On 21/06/13 08:31, SyedBhai wrote:
> Hi Everyone.
> Atlast I have figured out how to invoke a RESTFUL webservice using Camel
> Framework.
> It is very easy. No need of any CXF/CXFRS/RESTLET components.
> Just HTTP component of Camel is enough.
Sure that works too. Your original question had a JAX-RS code snippet
hence my suggestion to use JAX-RS aware components
Cheers, Sergey
>
> Thanks,
> Syed.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5734509.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: RestFul service using camel
Posted by SyedBhai <sy...@hotmail.com>.
Hi Everyone.
Atlast I have figured out how to invoke a RESTFUL webservice using Camel
Framework.
It is very easy. No need of any CXF/CXFRS/RESTLET components.
Just HTTP component of Camel is enough.
Thanks,
Syed.
--
View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5734509.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: RestFul service using camel
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
Have a look at this thread:
http://camel.465427.n5.nabble.com/Routing-from-servlet-to-CXF-JAXRS-via-direct-td5733746.html#a5733749
that option is about using (CXF) JAX-RS server endpoint and getting
Camel Servlet transport linked to it.
Also consider experimenting with CXFRS simple binding; perhaps a restlet
component cam help too
Sergey
On 19/06/13 18:14, SyedBhai wrote:
> THi Guys,
> My name is Syed.
> I have developed one JAX-RS webservice.
> In this webservice, the class is com.syed.WelcomeService (Its path is
> "/class1"). This class has a POST method.
> @Path("/post")
> @POST
> public String sayHello(String xyz) {...}
>
> I have deployed this webservice successfully in tomcat server. I even
> invoked the service using jersey client API.
>
> Now I want to invoke this webservice using camel framework in my client
> program.
> I am really having hard time how to invoke this service through camel.
> Can you please help me?
> I don't want the entire program.
> I just need the camel configuration to interact with the webservice.
> Please.
>
> Thanks,
> Syed.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5734395.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: RestFul service using camel
Posted by SyedBhai <sy...@hotmail.com>.
THi Guys,
My name is Syed.
I have developed one JAX-RS webservice.
In this webservice, the class is com.syed.WelcomeService (Its path is
"/class1"). This class has a POST method.
@Path("/post")
@POST
public String sayHello(String xyz) {...}
I have deployed this webservice successfully in tomcat server. I even
invoked the service using jersey client API.
Now I want to invoke this webservice using camel framework in my client
program.
I am really having hard time how to invoke this service through camel.
Can you please help me?
I don't want the entire program.
I just need the camel configuration to interact with the webservice.
Please.
Thanks,
Syed.
--
View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5734395.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: RestFul service using camel
Posted by Richa <rs...@gmail.com>.
Thank you for your reply Christian. It helped
--
View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5727018.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: RestFul service using camel
Posted by Christian Müller <ch...@gmail.com>.
Something like this:
https://github.com/muellerc/camel-in-daily-use/blob/master/part-2/src/main/java/org/apache/cmueller/camel/sus/cidu/part1/PrepareRestRequest.java
Best,
Christian
On Tue, Feb 5, 2013 at 5:56 AM, Richa <rs...@gmail.com> wrote:
> Thank you for your reply. But can you please help me with a sample code. I
> am
> trying to invoke my rest service using the cxfrs. I am putting the method
> name in the exchange header, but still I am not able to invoke the message
> and get the response. Kindly provide a sample code for my reference.
> Thank you
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5726939.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Re: RestFul service using camel
Posted by Richa <rs...@gmail.com>.
Thank you for your reply. But can you please help me with a sample code. I am
trying to invoke my rest service using the cxfrs. I am putting the method
name in the exchange header, but still I am not able to invoke the message
and get the response. Kindly provide a sample code for my reference.
Thank you
--
View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5726939.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: RestFul service using camel
Posted by Vincent Nonnenmacher <vi...@gmail.com>.
I don't known about cxf I admit, I was reasoning more along with the
Camel-Restlet component, and REST concepts in general.
So you're perhaps right for the Rest server part of CXF RS, that allow this
direct invocation by matching class/method by name in the URI as a Routing
method
On Fri, Feb 1, 2013 at 4:58 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
> Hi
>
> On 01/02/13 15:54, Vincent Nonnenmacher wrote:
>
>> It is your REST container responsibility to make the routing from an URI
>> to
>> a server class/method invocation.
>>
>> The camel part of the construct focus only on this URI.
>>
>> You could use a routing strategy that map by name some URI parts to invoke
>> a named method, but it still code that run on the server side.
>>
>> I think it is possible with CXF RS producer to introspect a given class
> and its method (with CXF proxy-based client runtime), and construct HTTP
> query, though I haven't used this option.
> Willem, can you give me a favor and clarify if possible ?
>
> Thanks, Sergey
>
>
>
>> On Friday, February 1, 2013, Richa wrote:
>>
>> Thank you Claus. I get your point. I want to invoke a rest service hosted
>>> in
>>> a remote server and hence should be putting the rest url in as a to
>>> endpoint.
>>>
>>> But i am unable to get through the format of the url to be passed as a TO
>>> endpoint. Firstly i am using cxfrs component to invoke the rest service
>>>
>>> How do i tell camel as to which function of the rest service should we
>>> invoke. My current webservice uri is
>>> cxfrs://http://localhost:8080/**CounterWebApp/?**resourceClasses=<http://localhost:8080/CounterWebApp/?resourceClasses=>
>>> "+Hello.class.getName()
>>>
>>> How do i mention the method name of the rest service ?
>>>
>>> Appreciate your help.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://camel.465427.n5.nabble.**com/RestFul-service-using-**
>>> camel-tp5726656p5726721.html<http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5726721.html>
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
Re: RestFul service using camel
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 01/02/13 15:54, Vincent Nonnenmacher wrote:
> It is your REST container responsibility to make the routing from an URI to
> a server class/method invocation.
>
> The camel part of the construct focus only on this URI.
>
> You could use a routing strategy that map by name some URI parts to invoke
> a named method, but it still code that run on the server side.
>
I think it is possible with CXF RS producer to introspect a given class
and its method (with CXF proxy-based client runtime), and construct HTTP
query, though I haven't used this option.
Willem, can you give me a favor and clarify if possible ?
Thanks, Sergey
>
> On Friday, February 1, 2013, Richa wrote:
>
>> Thank you Claus. I get your point. I want to invoke a rest service hosted
>> in
>> a remote server and hence should be putting the rest url in as a to
>> endpoint.
>>
>> But i am unable to get through the format of the url to be passed as a TO
>> endpoint. Firstly i am using cxfrs component to invoke the rest service
>>
>> How do i tell camel as to which function of the rest service should we
>> invoke. My current webservice uri is
>> cxfrs://http://localhost:8080/CounterWebApp/?resourceClasses=
>> "+Hello.class.getName()
>>
>> How do i mention the method name of the rest service ?
>>
>> Appreciate your help.
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5726721.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
Re: RestFul service using camel
Posted by Vincent Nonnenmacher <vi...@gmail.com>.
It is your REST container responsibility to make the routing from an URI to
a server class/method invocation.
The camel part of the construct focus only on this URI.
You could use a routing strategy that map by name some URI parts to invoke
a named method, but it still code that run on the server side.
On Friday, February 1, 2013, Richa wrote:
> Thank you Claus. I get your point. I want to invoke a rest service hosted
> in
> a remote server and hence should be putting the rest url in as a to
> endpoint.
>
> But i am unable to get through the format of the url to be passed as a TO
> endpoint. Firstly i am using cxfrs component to invoke the rest service
>
> How do i tell camel as to which function of the rest service should we
> invoke. My current webservice uri is
> cxfrs://http://localhost:8080/CounterWebApp/?resourceClasses=
> "+Hello.class.getName()
>
> How do i mention the method name of the rest service ?
>
> Appreciate your help.
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5726721.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: RestFul service using camel
Posted by Richa <rs...@gmail.com>.
Thank you Claus. I get your point. I want to invoke a rest service hosted in
a remote server and hence should be putting the rest url in as a to
endpoint.
But i am unable to get through the format of the url to be passed as a TO
endpoint. Firstly i am using cxfrs component to invoke the rest service
How do i tell camel as to which function of the rest service should we
invoke. My current webservice uri is
cxfrs://http://localhost:8080/CounterWebApp/?resourceClasses="+Hello.class.getName()
How do i mention the method name of the rest service ?
Appreciate your help.
--
View this message in context: http://camel.465427.n5.nabble.com/RestFul-service-using-camel-tp5726656p5726721.html
Sent from the Camel - Users mailing list archive at Nabble.com.