1 Reply Latest reply on Aug 16, 2004 9:57 PM by tabate

    Web Service Persistence

    alexb_1593

      Hi all,

      I have a stateful EJB (say ApiOamEJB) deployed as a web service with a session scope. The TestEJB in turn has a method Login, which calls an entity bean, which in turn checks user info in database before any other methods can be invoked. When the user successfully logs on, the state is reflected by setting a member variable inside ApiOamEJB equal to the user name (before Login, the user name member variable is empty). I have the following problem I invoke Login, and then another method of ApiOamEJB, when I invoke the second method, the ApiOamEJB still thinks I had not logged in. What is the problem?

      This is a source fragment from the ApiOam bean:

      public class ApiOamBean
      {
       private String userName = "";
      
       public void Login(String username,String password) throws RemoteException
       {
       ...
       LoginBean.Login(username,password);
       userName = username;
       }
      
       public void otherMethod() throws RemoteException
       {
       if(!userName.equals(""))
       {
       //do something
       }
       }
      }
      



      This is the source, used to invoke the web service:
       String endpoint = "http://localhost:8080/jboss-net/services/ApiOAM";
       Service srv = new Service();
       Call call = (Call)srv.createCall();
       call.setTargetEndpointAddress(new java.net.URL(endpoint));
       call.setOperationName("Login");
       call.invoke(new Object[] {"alexb","walnutsun3"});
      
      //at this point, the web service behaves as if Login had not been invoked
      //i.e. userName="", and of course, otherMethod fails to do its job
       call.setOperationName("otherMethod");
       call.invoke(new Object[] {});
      


      This is the web-service.xml file:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <deployment
       name="ApiOAM"
       xmlns="http://xml.apache.org/axis/wsdd/"
       targetNamespace="http://oamapi/ApiOAM"
       xmlns:ApiOAM="http://oamapi/ApiOAM"
       xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
      
       <service name="ApiOAM" provider="Handler">
       <parameter name="scope" value="Session"/>
       <parameter name="handlerClass" value="org.jboss.net.axis.server.EJBProvider" />
       <parameter name="beanJndiName" value="ApiOamJNDI" />
       <parameter name="allowedMethods" value="*" />
      
       <requestFlow name="ApiOAMRequest">
       </requestFlow>
       <responseFlow name="ApiOAMResponse">
       </responseFlow>
      
       </service>
      </deployment>