You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Russell Butek <bu...@us.ibm.com> on 2002/03/08 15:07:34 UTC

Re: deploy problem. would not work.

It isn't sufficient to tell the server that the service is session scope.
The client must be aware of it as well.

locator.setMaintainSession(true);

Russell Butek
butek@us.ibm.com


Akira Hirose <Ak...@fujixerox.co.jp> on 03/08/2002 12:39:50 AM

Please respond to axis-dev@xml.apache.org

To:    axis-dev@xml.apache.org
cc:
Subject:    deploy problem. <parameter name="scope" value="session"/> would
       not  work.



Hello,

 I tried to make the life span of a SOAP service object session wide
without success. I wrote a test service and a test client. If parameter
scope is "application" or "request", it works as I expected. But, when
scope is "session", test program behaves the same way when scope is
request.

 Would you mind tell me what is wrong. Or am I misunderstanding the
meaning of "session" scope? I appreciate any advice.


version:

Axis-beta1-RC1, Apache Tomcat 4.0.1, JDK 1.3.1_01
Windows NT 4.0 SP6.
Both service and client are running on identical machine.

Detail:

My test service is a Java class  LifeSpanTest which has an integer
variable and a getNext method which increment the variable and return
the value.
The client program Test.java repeats making getNext successive call to
the service. When the LifeSpaceTest service is deployed with scope
parameter "application", the client gives following result as I expected.

 clear
 test start
 (1): 1
 (2): 2
 test end
 test start
 (1): 3
 (2): 4
 test end

and, if scope is "request", it gives following result as I expected.

 clear
 test start
 (1): 1
 (2): 1
 test end
 test start
 (1): 1
 (2): 1
 test end

When I set scope "session", I expected,

 clear
 test start
 (1): 1
 (2): 2
 test end
 test start
 (1): 1
 (2): 2
 test end

But, result was.

 clear
 test start
 (1): 1
 (2): 1
 test end
 test start
 (1): 1
 (2): 1
 test end

Source code of the service LifeSpanTest.java, the deploy.wsdd,
and the test client Test1.java is below.

/* Test life span of a SOAP service object. */

public class LifeSpanTest {

 private int      counter;

 public LifeSpanTest() { counter = 0; };

 public int clear() { counter = 0; return counter; }

 public int getNext() { counter++; return counter; }


}

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

  <!-- Services from LifeSpanTest WSDL service -->

  <service name="LifeSpanTest" provider="java:RPC">
      <parameter name="className" value="LifeSpanTest"/>
      <parameter name="methodName" value="*"/>
<!--
      <parameter name="scope" value="application"/>
      <parameter name="scope" value="session"/>
      <parameter name="scope" value="request"/>
-->
      <parameter name="scope" value="session"/>
  </service>
</deployment>


/* Client */

package localhost;


public class Test1 {

 private static void clear() {
  try {
   int i;
   LifeSpanTestService  locator = new LifeSpanTestServiceLocator();
   LifeSpanTest svc = locator.getLifeSpanTest();
   System.out.println("clear");
   i = svc.clear();
  } catch ( Exception e ) {
   System.err.print(e);
  }
 }

 private static void test() {
  try {
   int i;
   LifeSpanTestService  locator = new LifeSpanTestServiceLocator();
   LifeSpanTest svc = locator.getLifeSpanTest();
   System.out.println("test start");
   System.out.println("(1): "+ String.valueOf(svc.getNext()) );
   System.out.println("(2): "+ String.valueOf(svc.getNext()) );
   System.out.println("test end");
  } catch ( Exception e ) {
   System.err.print(e);
  }
 }

 public static void main(String [] args) throws Exception {
  clear();
  test();
  test();
 }
}


 Thank you.

/* akira.hirose */



Re: deploy problem. would notwork.

Posted by Akira Hirose <Ak...@fujixerox.co.jp>.
Mr. Russell Butek,

Thank you for your prompt reply.

Although the behavior is bit different from I expected, but it worked fine.
A new client program, and its result are attached below.


Russell Butek wrote:
> 
> It isn't sufficient to tell the server that the service is session scope.
> The client must be aware of it as well.
> 
> locator.setMaintainSession(true);
> 
> Russell Butek
> butek@us.ibm.com
> 

The output of my test program. Third call block starts with 3, though I 
expected 1. So, it must be the same session of the first call block.

	test start
	(1): 1
	(2): 2
	test end
	test start
	(1): 1
	(2): 1
	test end
	test start
	(1): 3
	(2): 4
	test end
	test start
	(1): 5
	(2): 6
	test end


/* Client.java */

package localhost;


public class Test1 {

	private static void test(boolean maintainSession) {
		try {
			int i;
			LifeSpanTestServiceLocator  locator = new LifeSpanTestServiceLocator();
			locator.setMaintainSession(maintainSession);
			LifeSpanTest svc = locator.getLifeSpanTest();
			System.out.println("test start");
			System.out.println("(1): "+ String.valueOf(svc.getNext()) );
			System.out.println("(2): "+ String.valueOf(svc.getNext()) );
			System.out.println("test end");
		} catch ( Exception e ) {
			System.err.print(e);
		}
	}
	
	public static void main(String [] args) throws Exception {
		test(true);
		test(false);
		test(true);
		test(true);
	}
}



/* akira.hirose */