Hi,

You should get the parameter from the message body as a List.
In this way you could access the cookie as Sergey shows to you.


On Wed Jul 11 01:23:13 2012, javakurious wrote:

Sergey Beryozkin-3 wrote


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

Blog: http://sberyozkin.blogspot.com


Problem with @CookieParam solution is that I don't have an implementation of
these methods in the class. These methods don't get called. I specify these
methods just to configure jaxrs properties. The actual response is returned
by the camel route. So, I am looking to use @HttpHeader context injection in
one of the processor in the camel route.

If I use org.springframework.http.HttpHeaders, there is no getCookies()
method, if I use javax.ws.rs.core.HttpHeaders, then it is not getting
injected by camel.

So, I am still not sure how to set a cookie in the http response, for client
to send it back in the next request.

Thanks


--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-cxfrs-setting-a-cookie-in-the-http-response-tp5715788p5715819.html
Sent from the Camel - Users mailing list archive at Nabble.com.




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

Reply via email to