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]
--
Andrew Martin
Computer Programmer
Regenstrief Institute, Inc.
410 West 10th Street, Suite 2000
Indianapolis, IN 46202-3012
Phone: (317) 423-5542
Fax: (317) 423-5695
[EMAIL PROTECTED]
Confidentiality Notice: The contents of this message and any files
transmitted with it may contain confidential and/or privileged
information and are intended solely for the use of the named
addressee(s). Additionally, the information contained herein may have
been disclosed to you from medical records with confidentiality
protected by federal and state laws. Federal regulations and State laws
prohibit you from making further disclosure of such information without
the specific written consent of the person to whom the information
pertains or as otherwise permitted by such regulations. A general
authorization for the release of medical or other information is not
sufficient for this purpose.
If you have received this message in error, please notify the sender by
return e-mail and delete the original message. Any retention,
disclosure, copying, distribution or use of this information by anyone
other than the intended recipient is strictly prohibited.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]