Hi
On 10/07/12 13:55, javakurious wrote:
Hi Sergey,

Thanks for the reploy. My apologies if the question was posted in incorrect
forum. But, I was using Camel - CXF to implement the REST service, so I
thought this would be an appropriate forum. I am new to Camel and CXF,
therefore I might be little unclear on the question, itself.

Here is a little bit more detail of what I am doing. If you can provide a
little more explanation on your answer on where should the cookie be set, it
will be helpful for me.

My goal is to implement a WebService which can be accessed through HTTP GET.
So, following the example at  http://camel.apache.org/cxfrs.html CXFRS in
Camel , I added following configuration in the camel-config.xml

     <cxf:rsServer id="cgw-rest-server"
                          address="/"
                          serviceClass="com.rest.service.impl.ServiceImpl"/>

I have a bunch of methods defined in ServiceImpl class, which is only used
to configure jaxrs properties. camel route is actually creating the response
through a bunch of transformation.

     @GET
     @Path("/getCustomer")
     @Produces("text/xml")
     public Response getCustomer(
             @PathParam("name") String street) {
         throw new UnsupportedOperationException("Not supported yet.");
     }

So, if I understand you correctly, should I add a @CookieParam annotation as
a parameter. If so, will the value be passed in HTTP header for these cookie
?

Is there an example of using @Httpheaders as method parameter to get or set
the cookie.

Also, I am also not sure where to call Jax-RS response to return a cookie.


The simplest option is to do something like

@GET
      @Path("/getCustomer")
      @Produces("text/xml")
      public Response getCustomer(
              @PathParam("name") String street,
              @CookieParam("a") String aCookie) {
          if (aCookie == null) {
             // do some work
return Response.ok(someEntity).header("Set-Cookie", "a=b;Path=/services;Secure").build();
          } else {
             // use aCookie to identify the user state
          }
      }

Here is some more info:
http://cxf.apache.org/docs/jax-rs-basics.html

I believe that in Camel you can also use custom processors to set the out headers which I guess can let working with other HTTP components easier, however I agree it can be handy getting it all done inside a JAX-RS handler

HTH, Sergey

Thanks again for your reply. I will really appreciate if you could clarify
my confusion.



--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-cxfrs-setting-a-cookie-in-the-http-response-tp5715788p5715805.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

Reply via email to