cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: CXF Client not maintaing cookies
Date Tue, 11 Mar 2008 14:15:24 GMT
On Tuesday 11 March 2008, Wolf, Chris (IT) wrote:
> I will try it.
>
> BTW, is this the best way to deal with cookies on the *server* side?
> My concern is it is not portable.  Thanks.

Well, to make it portable, just change the keys:
AbstractHTTPDestination.HTTP_REQUEST and 
AbstractHTTPDestination.HTTP_RESPONSE
to MessageContext.SERVLET_REQUEST and MessageContext.SERVLET_RESPONSE.  
The rest of the code would remain the same.   That should work on all 
the JAX-WS implementations.

Dan



>
>
>   @Resource
>   public void setWebServiceContext(WebServiceContext ctx) {
>       context = ctx;
>   }
>
>   //Resource
>   public WebServiceContext getWebServiceContext() {
>       return context;
>   }
>
> [...]
> {
>  	MessageContext ctx = getWebServiceContext().getMessageContext();
>       // transport-specific request/response, cxf-specific property
> names
>       HttpServletRequest request = (HttpServletRequest)
> ctx.get(AbstractHTTPDestination.HTTP_REQUEST);
>       HttpServletResponse response = (HttpServletResponse)
> ctx.get(AbstractHTTPDestination.HTTP_RESPONSE);
>       Cookie[] cookies = request.getCookies();
> }
>
>
>
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Tuesday, March 11, 2008 9:24 AM
> To: cxf-user@incubator.apache.org
> Cc: Wolf, Chris (IT)
> Subject: Re: CXF Client not maintaing cookies
>
>
> Can you try with the 2.0.5 SNAPSHOT?
>
> Due to a bug in 2.0.4, only a single cookie is maintained on the
> client side.  Thus, if you have mulitple cookies, they won't all be
> maintained and sent back.   This is fixed with 2.0.5.
>
> The alternitive is to use a session on the server side.  The only
> cookie going back/forth would be the session cookie and any other
> state would be stored in the session.  Not ideal.
>
> Dan
>
> On Tuesday 11 March 2008, Wolf, Chris (IT) wrote:
> > I am trying to set an HTTP cookie from the CXF server.  It works
> > with a browser, but the generated CXF client does not keep or send
> > back cookies.  I tried the code:
> >
> > SecAdmin_Service ss = new SecAdmin_Service(wsdlURL, SERVICE_NAME);
> >SecAdmin port = ss.getSecadmin();  BindingProvider provider =
> >(BindingProvider)port;
> >provider.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PRO
> >P ER TY, true);
> >
> > ...as mentioned here:
> > http://www.nabble.com/JSESSIONID-cookie-not-sent-back-to-server-td15
> >51 40 55.html
> >
> > but it does not seem to be working.  I am using CXF-2.0.4.
> >
> > Thanks,
> >
> >    -Chris
> > --------------------------------------------------------
> >
> > NOTICE: If received in error, please destroy and notify sender.
> > Sender
> >
> > does not intend to waive confidentiality or privilege. Use of this
> > email is prohibited when received in error.
>
> --
> J. Daniel Kulp
> Principal Engineer, IONA
> dkulp@apache.org
> http://www.dankulp.com/blog
> --------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender
> does not intend to waive confidentiality or privilege. Use of this
> email is prohibited when received in error.



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Mime
View raw message