3 Replies Latest reply on Jul 9, 2006 11:36 AM by Cindy Taylor

    ServiceLifeCycle Question

    Burr Sutter Master

      I was experimenting with the ServiceLifeCycle in my 181 WS and it would appear that the session is recreated with every invocation/operation. Perhaps there is something in a config file that I need to setup. If so then the doc doesn't mention that fact:

      Here is my code, perhaps I simply built it incorrectly:

      package org.jboss.samples;
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.xml.rpc.server.ServiceLifecycle;
      import javax.xml.rpc.server.ServletEndpointContext;
      import javax.xml.rpc.ServiceException;
      import javax.xml.rpc.handler.MessageContext;
      import java.util.Iterator;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Use;
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      public class ExamineContext implements ServiceLifecycle {
       private ServletEndpointContext context;
       @WebMethod (operationName="GetUserPrincipalName")
       public String getUserPrincipalName() {
       return context.getUserPrincipal().getName();
       public String getAttribute(String key) {
       return (String) context.getHttpSession().getAttribute(key);
       public void setAttribute(String key, String value) {
       public void removeAttribute(String key) {
       public String getSessionId() {
       return context.getHttpSession().getId();
       public String getMessageContext() {
       MessageContext msgContext = context.getMessageContext();
       StringBuffer sb = new StringBuffer();
       String key = null;
       for(Iterator i = msgContext.getPropertyNames(); i.hasNext(); ) {
       key = (String) i.next();
       sb.append(";" + key + "=" + msgContext.getProperty(key));
       return sb.toString();
       public void init(Object context) throws ServiceException
       System.out.println("ExamineContext Init\n");
       this.context = (ServletEndpointContext)context;
       public void destroy()
       System.out.println("ExamineContext Destroy\n");


        • 1. Re: ServiceLifeCycle Question
          Thomas Diesler Master

          J2EE service endpoints are essentially stateless. For portable stateful behaviour independent of the transport layer see the user guide chapter on ws-addressing

          • 2. Re: ServiceLifeCycle Question
            Burr Sutter Master

            Thanks Thomas! Please modify the doc. The ServiceLifeCycle section comes directly after the JSR-181 section and it would seem that I (the reader) could take advantage of it.
            I've always worked under the assumption that messing with the HTTP Session was a no-no but the doc lead me to believe there was something I could go play with.

            I can add a Jira for this if you think it is appropriate and if needed make the adjustments to the doc for this particular behavior.


            • 3. Re: ServiceLifeCycle Question
              Cindy Taylor Newbie


              I am trying to understand what is exactly a stateful endpoint. I have looked and and run the example from jbossws-samples-1.0.1.GA - the wsaddressing example with the service StatefulEndpoint and it seems like the object gets recreated for each request with only the data in the static fields getting reset to what there were previously set to.

              I have tried to find documentation on the behavior of stateful endpoints but have not been able to. If someone knows of anything, please point me to it.

              I suppose that there is nothing in JBossWS that is similar to Axis 1.3's deployment scops of application, session, and request - at least I haven't been able to find it. Maybe that was not a standard feature but if someone does know of something, please post it.