Hi
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:
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.
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:
http://sberyozkin.blogspot.ie/2011/05/how-to-use-camel-transport-with-cxf-jax.html.
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
Exchange.HTTP_SERVLET_REQUEST or Exchange.HTTP_SERVLET_RESPONSE properties.
Hope you can get the cookies under control :-)
Sergey
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.