You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by paramjyotsingh <pa...@gmail.com> on 2012/08/14 20:32:48 UTC

cxfrs: GET and POST handling in bean

I am trying to expose restful service using camel:cxfrs

<cxf:rsServer address="http://localhost:8080" id="rsServer"
serviceClass="mypackage.ServiceClass"/>

<bean id="serviceBean" class="mypackage.Servicebean"/>

<camel:from uri="cxfrs://bean://rsServer"/>
<camel:bean ref="serviceBean"/>

@Path("/path")
public class ServiceClass {

  @GET
  @Path("{id}")
  public String getName(@PathParam("id") int id){
      // logic to get Name and return
  }

  @POST
  @Path("{id}")
  public void update(@PathParam("id") int id, String name){
      // logic to update name
  }
}

Now, in this case camel only uses these methods to expose service, these are
not actually invoked.

In ServiceBean class how should i write methods corresponding for GET and
POST methods.

Please help.



--
View this message in context: http://camel.465427.n5.nabble.com/cxfrs-GET-and-POST-handling-in-bean-tp5717342.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: cxfrs: GET and POST handling in bean

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 15/08/12 04:19, paramjyotsingh wrote:
> Is it not possible to handle it somehow in camel routes. Is there any way
> Camel identifies the request type like GET, POST, PUT or DELETE as we have
> for restful service and invoke the annotated method.
>
> I know i can use JAX-RS to handle calls to implementation bean, but is it
> possible to have similar thing when i expose restful service using camel
> route and have multiple service methods defined/declared.
>
>
You can use CXF directly if you'd like, specifically, declare 
jaxrs:endpoint and use Camel transport to link to it


Other Camel HTTP-centric components may offer something too

Cheers, Sergey
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/cxfrs-GET-and-POST-handling-in-bean-tp5717342p5717362.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: cxfrs: GET and POST handling in bean

Posted by paramjyotsingh <pa...@gmail.com>.
Is it not possible to handle it somehow in camel routes. Is there any way
Camel identifies the request type like GET, POST, PUT or DELETE as we have
for restful service and invoke the annotated method.

I know i can use JAX-RS to handle calls to implementation bean, but is it
possible to have similar thing when i expose restful service using camel
route and have multiple service methods defined/declared.



--
View this message in context: http://camel.465427.n5.nabble.com/cxfrs-GET-and-POST-handling-in-bean-tp5717342p5717362.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: cxfrs: GET and POST handling in bean

Posted by Willem jiang <wi...@gmail.com>.
Hi,

You can find the same example here[1], basic camel-cxfrs consumer just put the operation name and invocation parameters into the message, camel route can do the transformation as you want.  If you just want to use bean to provide the service, you can use CXF directly. 

[1]http://camel.apache.org/cxfrs.html 

-- 
Willem Jiang

FuseSource
Web: http://www.fusesource.com (http://www.fusesource.com/)
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang



On Wednesday, August 15, 2012 at 2:32 AM, paramjyotsingh wrote:

> I am trying to expose restful service using camel:cxfrs
> 
> <cxf:rsServer address="http://localhost:8080" id="rsServer"
> serviceClass="mypackage.ServiceClass"/>
> 
> <bean id="serviceBean" class="mypackage.Servicebean"/>
> 
> <camel:from uri="cxfrs://bean://rsServer"/>
> <camel:bean ref="serviceBean"/>
> 
> @Path("/path")
> public class ServiceClass {
> 
> @GET
> @Path("{id}")
> public String getName(@PathParam("id") int id){
> // logic to get Name and return
> }
> 
> @POST
> @Path("{id}")
> public void update(@PathParam("id") int id, String name){
> // logic to update name
> }
> }
> 
> Now, in this case camel only uses these methods to expose service, these are
> not actually invoked.
> 
> In ServiceBean class how should i write methods corresponding for GET and
> POST methods.
> 
> Please help.
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/cxfrs-GET-and-POST-handling-in-bean-tp5717342.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).