Andrew,

I tried what you suggested but I am still getting the same behavior as before.

Also, if I set scope to "application" it DOES maintain the class variable, but when I try "session" it acts like requested.

Any other suggestions?

Thanks,
Jim





Andrew Martin wrote:
Try this:

public String setKey()
{
        getSession().set("keyValue", "theValue");
        return "value was set in private member variable";
}

public String getKey()
{
        String msg = "";
        String keyValue = (String) getSession().get("keyValue");
        if(keyValue==null)msg = "Session state is not being maintained";
        else msg += "keyValue= " + keyValue;
        return msg;
}

private Session getSession()
{
        MessageContext mc = MessageContext.getCurrentContext();

        mc.setMaintainSession(true); // Setup the session

        return mc.getSession();
}

Andrew

James Neff wrote:
Greetings,

I'm trying to get Axis 1.4 to maintain a session for me.

Here is my Java class:

public class StatefulService {

   private String keyValue;                //this is the 'state' being
maintained

   public String setKey() {
       keyValue = "theValue";
       return "value was set in private member variable";
   }

   public String getKey() {
       String msg = "";
       if(keyValue==null)msg = "Session state is not being maintained";
                    else msg += "keyValue= " + keyValue;
       return msg;
   }
}

Here is my client, a jsp being called via Ajax:

<%@ page language="java"
    import="org.apache.axis.client.Call,
        org.apache.axis.client.Service,
        org.apache.axis.encoding.XMLType,
        javax.xml.rpc.ParameterMode,
        javax.xml.namespace.QName,
        java.net.URL" %>

<%
   String ret = "yada";
     String endpointURL =
"http://localhost:8080/axis/services/StatefulService";;
       try {
           Service  service = new Service();
           Call     call    = (Call) service.createCall();
           call.setTargetEndpointAddress( new java.net.URL(endpointURL) );
           call.setReturnType( XMLType.XSD_STRING );
call.setMaintainSession(true); call.setOperationName( "getKey" );
           ret = ret + (String) call.invoke( new Object[] { } );
       ret = ret + "\n";
           call.setOperationName( "setKey" );
ret = ret + (String) call.invoke( new Object[] { } ); ret = ret + "\n";
           call.setOperationName( "getKey" );
           ret = ret + (String) call.invoke( new Object[] { } );
       } catch (Exception e) {
      ret = e.toString();
       }
     out.println(ret);

%>

Here is my WSDD file I am using to deploy the web service:

<deployment xmlns="http://xml.apache.org/axis/wsdd/";
           xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>

<service name="StatefulService" provider="java:RPC">
 <parameter name="className" value="StatefulService"/>
 <parameter name="allowedMethods" value="*"/>
 <parameter name="scope" value="session"/>
</service>

</deployment>



When I call this the first time I get:
   Session State is not being maintained
   value was set in private member variable
   keyValue=theValue

When I call it the second time I get the same thing, but I expect:

   keyValue=theValue
   value was set in private member variable
   keyValue=theValue


What in the world am I doing wrong?  I've been baning my head against a
wall over this for 2 days reading and trying every example online that I
can find.

Much Thanks in Advance,
Jim


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--

James Neff
Technology Specialist

Tethys Health Ventures
4 North Park Drive, Suite 203
Hunt Valley, MD  21030

office:  410.771.0692 x103
cell:    443.865.7874

Reply via email to