Ah! Ok.
You CAN share the session across clients, but you'll need to do a bit of CXF
proprietary work to do it. Basically you have to extract out the Cookie
from the response and set it into other clients.
To extract it, the easiest is to get the HTTP_RESPONSE_HEADERS from the
response context and find the Set-Cookie headers and record them. You may
need to process them a little, but nothing major.
To set the cookie on other clients, do:
Client client = ClientProxy.getClient(proxy);
Conduit conduit = client.getConduit();
if(conduit instanceof HTTPConduit) {
HTTPClientPolicy policy = ((HTTPConduit)conduit).getClient();
if(policy == null) {
policy = new HTTPClientPolicy();
((HTTPConduit)conduit).setClient(policy);
}
policy.setCookie(/*value of the Cookie: header*/);
Some of this was taken from some work Ian Roberts discussed on:
http://www.nabble.com/Custom-HTTP-Headers-to19775288.html#a19776735
Hope that helps!
Dan
On Monday 03 November 2008 2:09:12 pm Rajeev jha wrote:
> Thanks Dan.
> I have looked at this option, Implementing it the way
> http://weblogs.java.net/blog/ramapulavarthi/archive/2006/06/maintaining_ses
>.html described here . The issue however is , I am *not sure* how to use
> this in our setup because of the way we are layering our application .
>
> AFAIK, The scope of JAX-WS sessions are tied to JAX-WS clients , if the
> client dies then effectively the session also dies. If you start a new
> client then effectively you are starting a new session. How will this
> session mechanism work if you have to call JAX-WS web services to render
> data for a browser application? Earlier the browser was just one
> application keeping track of one cookie from one server. Now the problem is
> every new JAX-WS client invocation means a new COOKIE.
>
> Thanks again
>
> -rajeev
>
>
>
>
>
> JAX-WS clients must support sessions via cookies. You need to turn it on
> though.
>
> ((BindingProvider)port).getRequestContext().put(
> BindingProvider.SESSION_MAINTAIN_PROPERTY, "true");
>
> Dan
>
> On Thursday 30 October 2008 9:41:49 am Rajeev jha wrote:
> > Hi
> > We have a requirement to implement an http session like scheme for our
> > CXF web services. Essentially you connect to web service and receive an
> > identifier. Later you present that identifier and that is how web service
> > "remembers" you. standard http session stuff. We believe this cookies
> > over
> > SSL scheme is good enough for our purpose.
> >
> > The problem is, since these are SOAP APIs we need some
> > library/implementation that works like http session handling (but without
> > http web requests). I would like to ask if anyone is aware of some
> > libraries that let you generate identifier tokens with expiry time stamp?
--
Daniel Kulp
[EMAIL PROTECTED]
http://dankulp.com/blog