I've been working on HttpSession support in Axis for the last couple days and a new ServletSessionHandler (based loosely on SimpleSessionHandler) to implement the integration. The integration isn't as simple as one would think.
As you alluded to, you'll have to get rid of any calls to context.getSession() in your services. When you first execute the code you referenced:
MessageContext context = MessageContext.getCurrentContext();
HttpServletRequest req = (HttpServletRequest) context.getProperty(
HTTPConstants.MC_HTTP_SERVLETREQUEST);
req.getSession(true);
your appserver creates an HttpSession and sends back the JSESSIONID as an Http header. Depending on whether your client supports Java sessions (some do, some don't, Axis client does if setMaintainSession() is true), this will get returned on the next call from the client. Calls to the above code in whatever service is called the second time will get you the same HttpSession you created on the first call.
Using SOAPHeaders to accomplish the same is more complex.
You're doing something wrong if the HttpSessionListener doesn't get hit from the service -- it should. This could be symptomatic of something else.
justin
At 06:13 PM 10/16/2003, you wrote:
what i want to do is to create a session in the soap service and then access the same session in a servlet. In my understanding if i create a session in service using
MessageContext context = MessageContext.getCurrentContext();
HttpServletRequest req = (HttpServletRequest) context.getProperty(
HTTPConstants.MC_HTTP_SERVLETREQUEST);
req.getSession(true);
Now in my servlet i already have a request object and so when i do requestObj.getSession() i should get the same session object which was created in the services. However this does not happen.
Also i have implemented a HttpSessionListener which does not work when i create a session in SOAPService but works when session is created in a servlet.
How do i resolve these issues.
thanks
abhijat
-----Original Message----- From: Henrik Vendelbo [mailto:[EMAIL PROTECTED] Sent: Thursday, October 16, 2003 6:08 PM To: [EMAIL PROTECTED] Subject: Re: sharing session between servlets and soap services
Apparently the session support is still being worked on, although I have little clue what the plans are.
You can sub-class the AxisServlet if you need to access servlet functionality until then
----- Original Message ----- From: "Abhijat Thakur" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 17, 2003 1:12 AM Subject: sharing session between servlets and soap services
I have apache axis running under Tomcat. However session created in a service cannot be accessed in a regular servlet even though the servlet and the soap service are under the same instance of Tomcat. How can we share sessions between servlets and soap services.
thanks
abhijat
____________________________________ Justin Ruthenbeck Software Engineer, NextEngine Inc. justinr - AT - nextengine DOT com Confidential See http://www.nextengine.com/confidentiality.php ____________________________________
