[jboss-user] [JBoss Web Services CXF] - How to share session between web service calls?

Anand Jayaraman do-not-reply at jboss.com
Mon Aug 16 05:58:39 EDT 2010


Anand Jayaraman [http://community.jboss.org/people/anand201301] replied to the discussion

"How to share session between web service calls?"

To view the discussion, visit: http://community.jboss.org/message/557502#557502

--------------------------------------------------------------
Hi,

I tried the above approach. It didn't work for me. I can clearly see two different JSESSIONIDs between the request/response. However when i use the HttpConduit approach the JSESSIONIDs are exactuly the same between the two request/responses.I am pasting the code i am trying out below:




String target =
"http://localhost:9090/CXFDemo";
IHelloService service =
*new IHelloService();IHello stub = service.getIHelloPort();
BindingProvider bp = (BindingProvider)stub;
bp.getRequestContext().put(BindingProvider.
+ENDPOINT_ADDRESS_PROPERTY, target);bp.getRequestContext().put(BindingProvider.
+SESSION_MAINTAIN_PROPERTY, *true); 
Map<String, List<String>> headers= CastUtils.+cast+((Map)bp.getRequestContext().get(
"javax.xml.ws.http.request.headers")); 
// This turns out to be null. 
*if (headers == *null) {headers =
*new HashMap<String, List<String>>();bp.getRequestContext().put(
"javax.xml.ws.http.request.headers", headers);}
List<String> cookies = Arrays.+asList+(
*new String[] {"a=a","b=b"});headers.put(
"Cookie", cookies); String str = stub.hello(
"hello world!!");

//Creating a second service instance IHelloService service1 =
*new IHelloService();IHello stub1 = service1.getIHelloPort();
BindingProvider provider1 = (BindingProvider)stub1;
provider1.getRequestContext().put(BindingProvider.
+ENDPOINT_ADDRESS_PROPERTY, target);provider1.getRequestContext().put(BindingProvider.
+SESSION_MAINTAIN_PROPERTY, *true);
Map<String, List<String>> headers1= CastUtils.+cast+((Map)provider1.getRequestContext().get(
"javax.xml.ws.http.request.headers"));

*if (headers1 == *null) {headers1 =
*new HashMap<String, List<String>>();
// Putting back the headers from the first request.provider1.getRequestContext().put(
"javax.xml.ws.http.request.headers", headers);}
String greeting = stub1.hello(
"Bonjour");


Please let me know if i need to correct something?


Regards,
Anand
*++******++****


*
**

*+
+
*



*

*
**


*+
+
*


*++******++****

*
**

*+
+
*



*

*
**


*+
+
*


*++******++****
*
**

*+
+
*



*

*
**


*+
+
*

**++******++****
*
**

*+
+
*



*

*
**


*+
+
*


***++******++***
**

*+
+
*



*

*
**


*+
+
*



*++******++*
*+
+
*



*

*
**


*+
+
*

*+*++******++*
*+
+
*



*

*
**


*+
+
*


+*++******+
+
*



*

*
**


*+
+
*


**++******
*



*

*
**


*+
+
*



*++*****


*

*
**


*+
+
*


*++*****

*

*
**


*+
+
*


*++*****
*

*
**


*+
+
*

**++*****
*

*
**


*+
+
*



*++****
*
**


*+
+
*

**++****
*
**


*+
+
*


***++***
**


*+
+
*



*++*

*+
+
*


*++*
*+
+
*

*+*++*
*+
+
*


+*+
+
*


**
*






--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/557502#557502]

Start a new discussion in JBoss Web Services CXF at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2046]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100816/e72cab96/attachment-0001.html 


More information about the jboss-user mailing list