You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "binh.le" <lx...@gmail.com> on 2015/04/22 01:14:12 UTC

JAX-RS How to manage the session/cookies in JAXRSClientFactory ?

Hi all,
I use cxf-wadl2java-plugin to generate codes from a wadl file.
I consume the generated codes with JAXRSClientFactory in cxf-rt-rs-client
package. It works well. I can manage to login to server and parse the
response.
But when i try to do anything else after i receive
"javax.ws.rs.NotAuthorizedException: HTTP 401 Unauthorized". Most likely i
have a problem of holding the session/cookie in the next request. 
Is there a way to manage the session/cookies setting in JAXRSClientFactory ?

Any help is much appreciated.
Best regards,
Binh



--
View this message in context: http://cxf.547215.n5.nabble.com/JAX-RS-How-to-manage-the-session-cookies-in-JAXRSClientFactory-tp5756380.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: JAX-RS How to manage the session/cookies in JAXRSClientFactory ?

Posted by "binh.le" <lx...@gmail.com>.
It works.

Thank for your help.



--
View this message in context: http://cxf.547215.n5.nabble.com/JAX-RS-How-to-manage-the-session-cookies-in-JAXRSClientFactory-tp5756380p5756539.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: JAX-RS How to manage the session/cookies in JAXRSClientFactory ?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Sure, CXF specific and HTTP centric options are available,

The CXF approach is to register a property,
org.apache.cxf.message.Message.MAINTAIN_SESSION, example,

WebClient.getConfig(client).getRequestContext().put(Message.MAINTAIN_SESSION, 
true);

otherwise write a code that gets a JAX-RS Response, gets Set-Cookie, and 
then sets Cookie on outbound request. You can get Response from a proxy 
with a WebClient.client(proxy).getResponse(), and set the extra headers 
similarly...

HTH, Sergey

On 22/04/15 00:14, binh.le wrote:
> Hi all,
> I use cxf-wadl2java-plugin to generate codes from a wadl file.
> I consume the generated codes with JAXRSClientFactory in cxf-rt-rs-client
> package. It works well. I can manage to login to server and parse the
> response.
> But when i try to do anything else after i receive
> "javax.ws.rs.NotAuthorizedException: HTTP 401 Unauthorized". Most likely i
> have a problem of holding the session/cookie in the next request.
> Is there a way to manage the session/cookies setting in JAXRSClientFactory ?
>
> Any help is much appreciated.
> Best regards,
> Binh
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/JAX-RS-How-to-manage-the-session-cookies-in-JAXRSClientFactory-tp5756380.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>