Java Mailing List Archive

Mailing List
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
Subject: - How can we manage session using JAX-WS?

Subject: - How can we manage session using JAX-WS?

2007-10-01       - By contactnag


We are currently using the Jboss 4.0.5 GA, JAX-WS webservices. I am trying to
implement session management.  I am getting WebServiceContext injection is null
.  Please find the code below which I have implemented Server and client side
for session management. Can anyone help me why I am getting WebServiceContext
null. If you have any code works on Jboss4.0.5 it is really helpful for me

Server Side code
-- ---- ---- ---- --
* Created on September 24, 2007, 10:42 AM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.

package cisco;

import javax.jws.*;
import javax.annotation.Resource;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.http.HttpSession;

public class Hello {    
    * WebServiceContext is injected by the JAX-WS Runtime
   private WebServiceContext wsContext;

    * another way to inject WebServiceContext
    * make sure this is not a WebMethod
    @(protected)(exclude = true)
    @(protected) public void initializeContext(WebServiceContext wsContext) {
    System.out.println("Setting WebServiceContext");
    this.wsContext = wsContext;
   public int getCounter() {
       MessageContext mc = wsContext.getMessageContext();
       HttpSession session = ((javax.servlet.http.HttpServletRequest) mc.get
       // Get a session property "counter" from context
       if (session == null)
           throw new WebServiceException("No session in WebServiceContext");
       Integer counter = (Integer) session.getAttribute("counter");
       if (counter == null) {
           counter = new Integer(0);
           System.out.println("Starting the Session");
       counter = new Integer(counter.intValue() + 1);
       session.setAttribute("counter", counter);
       return counter;


    * Lifecycle method called before servicing any requests
   @(protected)(exclude = true)
   public void onBeginService() {
       System.out.println("Called onBeginService: Session test");
       // Initialize resources need by the Service
       // ....

    * Lifecycle method called before destroying the service instance
   @(protected)(exclude = true)
   public void onEndService() {
       System.out.println("Called onEndService: Session test");
       // Clean up resources need by the Service
       // ....

Client Clode:
      try {
       cisco.HelloService service = new cisco.HelloService();
       cisco.Hello port = service.getHelloPort();
_MAINTAIN_PROPERTY,new Boolean(true));
       // TODO process result here
       //int result = port.getCounter();
       //out.println("Result = "+result);
       //Hello proxy = new HelloService().getHelloPort();
       int result = port.getCounter();
       result = port.getCounter();
       } catch (Exception ex) {

View the original post :

Reply to the post :
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
jboss-user mailing list

©2008 - Jax Systems, LLC, U.S.A.