camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <>
Subject Re: camel cxfrs : setting a cookie in the http response
Date Wed, 11 Jul 2012 09:03:06 GMT
On 10/07/12 18:23, 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:
>> 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:
> 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.

To be honest I don't even understand how a NO-OP cxfrs endpoint can be 
used :-). I do find it confusing and perhaps Willem and myself can 
review what can be improved, I'll be happy to contribute to it, fixing 
whatever is needed at the CXF level.
I thought users were able to use a bean variant, 'from:mybean', as an 
alternative. Another option is to use a CXF jaxrs:endpoint directly, 
please see:

If you prefer using the current approach, please follow the advice from 
Willem (guess that will allow to set the response headers). Perhaps you 
can also work with the current in/out Camel message headers, you can get 
to them via, for example, exchange.getIn().getHeaders() or 
exchange.getOut().getHeaders(), or may be even work with Camel 

Hope you can get the cookies under control :-)


> 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, 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:
> Sent from the Camel - Users mailing list archive at

View raw message