cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud DSA <arnaud....@gmail.com>
Subject Maintaining session in multi threaded application for Spring jaxws client
Date Fri, 25 Jun 2010 22:47:29 GMT

Hi,

I used the cxf+spring sample :
http://cxf.apache.org/docs/writing-a-service-with-spring.html

And I need to:
- share a the proxy amongst different threads
- maintain sessions for each thread as I need to call three functions in
sequence: login/execute/logout

But I see in the doc
(http://cxf.apache.org/faq.html#FAQ-AreJAXWSclientproxiesthreadsafe?) that
the proxy is not thread safe in this case:
-----
*  Session support - if you turn on sessions support (see jaxws spec), the
session cookie is stored in the conduit. Thus, it would fall into the above
rules on conduit settings and thus be shared across threads.
For the conduit issues, you COULD install a new ConduitSelector that uses a
thread local or similar. That's a bit complex though.
-----
The doc mentions a "complex" solution but I could not fin more information
on this.


I tried to manually handle the cookie by fetching it into a thread local and
putting it back on each request instead of using maintainSession, but I
could not get the session cookie from the client.

My client is loaded from spring like this:
-----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

    <jaxws:client id="helloClient"
                  serviceClass="demo.spring.HelloWorld"
                  address="http://localhost:9002/HelloWorld" />
</beans>
-----
ApplicationContext context = new
ClassPathXmlApplicationContext("client.xml");
HelloWorld client = (HelloWorld) context.getBean("helloClient");
-----

I can cast the client to a BindingProvider, but I did not find a way to
fetch the session cookie from here:
BindingProvider bp = (BindingProvider) client;

Could someone tell me how to fetch and set the session cookie from the
client, or point me to another solution?

Thanks in advance.
--
Arnaud
-- 
View this message in context: http://old.nabble.com/Maintaining-session-in-multi-threaded-application-for-Spring-jaxws-client-tp28997255p28997255.html
Sent from the cxf-user mailing list archive at Nabble.com.


Mime
View raw message