RE: Axis2 1.1.1 session works fine in browser but doesn't work in Stub client.

2007-01-29 Thread Zhou, Sam

Hi,


Actually The web service works perfectly when I use browser to invoke
the web service from
http://localhost:8080/axis2/rest/MySessionService/plusone. It returns
exactly 1,2,3, ..., n when I refresh n times.

The client Stub returns only 1,1,1... (should be 1,2,3...), even if I
call multiple times in the same stub. I used tcpip monitor to track the
raw traffic, the stub call doesn't contain JSESSIONID cookie at all.
That is also explained why browser invocation remembered session but
stub invocation didn't. Although I followed the step to enable session
in client stub 

stub._getServiceClient().getOptions().setManageSession(true);

somewhere in stub settings is not right because it doesn't return
JSESSIONID to server at all. The 1,1,1 returns are caused by server
treating each call as a new session. 


You can download the source code from
https://issues.apache.org/jira/secure/attachment/12349699/Axis2+MySessio
nService.zip

Bug#
https://issues.apache.org/jira/browse/AXIS2-2042


To: Sanjiva, I need SessionContext instead of ServiceContext, 

private SessionContext getSessionContext() {
MessageContext messageContext = MessageContext
.getCurrentMessageContext();

SessionContext sessionContext = null;
if(messageContext != null) {
sessionContext =
messageContext.getSessionContext();
}

return sessionContext;
}   

To: Deepal, I've also enabled transportsession in service.xml

..

..

Thanks,
Sam.

-Original Message-
From: Deepal Jayasinghe [mailto:[EMAIL PROTECTED] 
Sent: Sunday, January 28, 2007 11:44 PM
To: axis-user@ws.apache.org
Subject: Re: Axis2 1.1.1 session works fine in browser but doesn't work
in Stub client.

Hi ;

SessionContext is the one which keep transport dependent session data ,
and that will be only created if the service is deployed in transport
session.

Thanks
Deepal

Sanjiva Weerawarana wrote:

>H. I think your getSessionContext() should be modified to do 
>messageContext.getServiceContext(). Can you see whether that works?
>
>I'm not sure what sessionContext is .. have to look around :(.
>
>Sanjiva.
>
>On Fri, 2007-01-26 at 13:59 -0500, Zhou, Sam wrote:
>  
>
>>Hi,
>>
>> 
>>
>>I developed the following sample code using Axis 2 with session 
>>management. The service is very simple, it has a single method called 
>>plusone(). Whenever you call plusone() with session enabled, it will 
>>return counter++. The counter is initialized to 0 in init() and stored

>>in session.
>>
>> 
>>
>>I believe the server side code works fine, because after I deployed 
>>MySessionService.aar, if I use my browser to refresh
>>
>>http://localhost:8080/axis2/rest/MySessionService/plusone
>>
>> 
>>
>>It will return 1, 2, 3, 4, 5, 6, etc.
>>
>> 
>>
>>However, in my Stub client test code, even if I coded
>>
>> 
>>
>>stub._getServiceClient().getOptions().setManageSession(true);
>>
>> 
>>
>>All the 3 direct stub.plusone() calls only return 1, 1, 1 instead of 
>>1, 2, 3.
>>
>> 
>>
>>Attached are source codes in zip file. If you want to regenerate codes

>>from scratch, please use README.TXT. All the codes should work fine in

>>Eclipse 3.2.1 except I removed libraries of Axis2 and JUnit.
>>
>> 
>>
>>Please note I set the session scope to transport session in 
>>service.xml.
>>
>> 
>>
>>I really appreciate if somebody could tell me what part in my code is 
>>wrong and why the session doesn't work for Stub. I can email you the 
>>source code if you need it. I cannot attach to axis-user group, it is 
>>regarded as spam.
>>
>> 
>>
>>Thanks a lot,
>>
>>
>>Sam.
>> 
>>=== MySessionServiceTest.java = package 
>>com.compuware.axis2.gen;
>> 
>>public class MySessionServiceTest extends junit.framework.TestCase {
>> 
>> public void testplusone() throws java.lang.Exception {
>> 
>>  com.compuware.axis2.gen.MySessionServiceStub stub = new 
>>com.compuware.axis2.gen.MySessionServiceStub(
>>"http://localhost:8080/axis2/services/MySessionService/plusone";);
>>  stub._getServiceClient().getOptions().setManageSession(true);
>>  
>>  System.out.println("plusone()=" + stub.plusone().get_return());  
>> System.out.println("plusone()=" + stub.plusone().get_return());  
>> System.out.println("plusone()=" + stub.plusone().get_return());
>> 
>> }
&g

RE: Axis2 1.1.1 session works fine in browser but doesn't work in Stub client.

2007-01-26 Thread Zhou, Sam
Dims,

I uploaded source code to 
https://issues.apache.org/jira/secure/attachment/12349699/Axis2+MySessio
nService.zip

Bug#
https://issues.apache.org/jira/browse/AXIS2-2042

Thanks,
Sam.


-Original Message-
From: Davanum Srinivas [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 26, 2007 2:11 PM
To: axis-user@ws.apache.org
Subject: Re: Axis2 1.1.1 session works fine in browser but doesn't work
in Stub client.

Sam,

Please create a bug report, there is a link there to upload a zip/tar.

https://issues.apache.org/jira/browse/AXIS2

thanks,
dims

On 1/26/07, Zhou, Sam <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> Hi,
>
>
>
> I developed the following sample code using Axis 2 with session
management.
> The service is very simple, it has a single method called plusone().
> Whenever you call plusone() with session enabled, it will return
counter++.
> The counter is initialized to 0 in init() and stored in session.
>
>
>
> I believe the server side code works fine, because after I deployed 
> MySessionService.aar, if I use my browser to refresh
>
> http://localhost:8080/axis2/rest/MySessionService/plusone
>
>
>
> It will return 1, 2, 3, 4, 5, 6, etc.
>
>
>
> However, in my Stub client test code, even if I coded
>
>
>
> stub._getServiceClient().getOptions().setManageSession(true);
>
>
>
> All the 3 direct stub.plusone() calls only return 1, 1, 1 instead of 
> 1, 2, 3.
>
>
>
> Attached are source codes in zip file. If you want to regenerate codes

> from scratch, please use README.TXT. All the codes should work fine in

> Eclipse
> 3.2.1 except I removed libraries of Axis2 and JUnit.
>
>
>
> Please note I set the session scope to transport session in
service.xml.
>
>
>
> I really appreciate if somebody could tell me what part in my code is 
> wrong and why the session doesn't work for Stub. I can email you the 
> source code if you need it. I cannot attach to axis-user group, it is
regarded as spam.
>
>
>
> Thanks a lot,
> Sam.
>
> === MySessionServiceTest.java = package 
> com.compuware.axis2.gen;
>
> public class MySessionServiceTest extends junit.framework.TestCase {
>
>  public void testplusone() throws java.lang.Exception {
>
>   com.compuware.axis2.gen.MySessionServiceStub stub = new 
> com.compuware.axis2.gen.MySessionServiceStub(
>
> "http://localhost:8080/axis2/services/MySessionService/plusone";);
>
> stub._getServiceClient().getOptions().setManageSession(true);
>
>   System.out.println("plusone()=" + stub.plusone().get_return());
>   System.out.println("plusone()=" + stub.plusone().get_return());
>   System.out.println("plusone()=" + stub.plusone().get_return());
>
>  }
>
>  public org.apache.axis2.databinding.ADBBean getTestObject(
>java.lang.Class type) throws Exception {
>   return (org.apache.axis2.databinding.ADBBean)
> type.newInstance();
>  }
> }
>
>  MySessionServiceSkeleton.java === package 
> com.compuware.axis2.gen;
>
> import org.apache.axis2.context.*;
> import com.compuware.axis2.xsd.*;
> import org.apache.axis2.transport.http.*;
>
> public class MySessionServiceSkeleton implements
>   MySessionServiceSkeletonInterface {
>
>  private static String PROP_COUNTER = "property.counter";
>
>  public com.compuware.axis2.xsd.PlusoneResponse plusone() {
>   printMessage("plusone()", "begin");
>
>   SessionContext sessionContext = getSessionContext();
>
>   int counter = 1 + ((Integer)
> sessionContext.getProperty(PROP_COUNTER)).intValue();
>   sessionContext.setProperty(PROP_COUNTER, new Integer(counter));
>
>   printMessage("plusone()",
> "sessionContext="+sessionContext+", counter="+counter);
>
>   PlusoneResponse response = new PlusoneResponse();
>
>   response.set_return(counter);
>   return response;
>
>  }
>
>  public void init(ServiceContext serviceContext) {
>   printMessage("init()", "begin");
>
>   SessionContext sessionContext = getSessionContext();
>   sessionContext.setProperty(PROP_COUNTER, new Integer(0));
>
>   printMessage("init()",
> "sessionContext="+sessionContext+", reset counter to 1 in session");  
> }
>
>  public void destroy(ServiceContext serviceContext) {
>   printMessage("destroy()", "begin");
>
>   SessionContext sessionContext = getSessionContext();
>   sessionContext.getProperties().remove(PROP_COUNTER);
>
>   printMessage("destroy()",
> "sessionContext="+sessionContext+", remove counte

Axis2 1.1.1 session works fine in browser but doesn't work in Stub client.

2007-01-26 Thread Zhou, Sam
Hi,

 

I developed the following sample code using Axis 2 with session
management. The service is very simple, it has a single method called
plusone(). Whenever you call plusone() with session enabled, it will
return counter++. The counter is initialized to 0 in init() and stored
in session. 

 

I believe the server side code works fine, because after I deployed
MySessionService.aar, if I use my browser to refresh

http://localhost:8080/axis2/rest/MySessionService/plusone
http://localhost:8080/axis2/rest/MySessionService/plusone> 

 

It will return 1, 2, 3, 4, 5, 6, etc.

 

However, in my Stub client test code, even if I coded

 

stub._getServiceClient().getOptions().setManageSession(true);

 

All the 3 direct stub.plusone() calls only return 1, 1, 1 instead of 1,
2, 3.

 

Attached are source codes in zip file. If you want to regenerate codes
from scratch, please use README.TXT. All the codes should work fine in
Eclipse 3.2.1 except I removed libraries of Axis2 and JUnit.

 

Please note I set the session scope to transport session in service.xml.

 

I really appreciate if somebody could tell me what part in my code is
wrong and why the session doesn't work for Stub. I can email you the
source code if you need it. I cannot attach to axis-user group, it is
regarded as spam. 

 

Thanks a lot,

Sam.
 
=== MySessionServiceTest.java =
package com.compuware.axis2.gen;
 
public class MySessionServiceTest extends junit.framework.TestCase {
 
 public void testplusone() throws java.lang.Exception {
 
  com.compuware.axis2.gen.MySessionServiceStub stub = new
com.compuware.axis2.gen.MySessionServiceStub(
"http://localhost:8080/axis2/services/MySessionService/plusone";);
  stub._getServiceClient().getOptions().setManageSession(true);
  
  System.out.println("plusone()=" + stub.plusone().get_return());
  System.out.println("plusone()=" + stub.plusone().get_return());
  System.out.println("plusone()=" + stub.plusone().get_return());
 
 }
 
 public org.apache.axis2.databinding.ADBBean getTestObject(
   java.lang.Class type) throws Exception {
  return (org.apache.axis2.databinding.ADBBean) type.newInstance();
 }
}

 MySessionServiceSkeleton.java ===
package com.compuware.axis2.gen;
 
import org.apache.axis2.context.*;
import com.compuware.axis2.xsd.*;
import org.apache.axis2.transport.http.*;
 
public class MySessionServiceSkeleton implements
  MySessionServiceSkeletonInterface {
 
 private static String PROP_COUNTER = "property.counter";
 
 public com.compuware.axis2.xsd.PlusoneResponse plusone() {
  printMessage("plusone()", "begin");
  
  SessionContext sessionContext = getSessionContext();
  
  int counter = 1 + ((Integer)
sessionContext.getProperty(PROP_COUNTER)).intValue();
  sessionContext.setProperty(PROP_COUNTER, new Integer(counter));
  
  printMessage("plusone()", "sessionContext="+sessionContext+",
counter="+counter);
  
  PlusoneResponse response = new PlusoneResponse();
  
  response.set_return(counter);
  return response;
  
 }
 
 public void init(ServiceContext serviceContext) {
  printMessage("init()", "begin");
  
  SessionContext sessionContext = getSessionContext();
  sessionContext.setProperty(PROP_COUNTER, new Integer(0));
  
  printMessage("init()", "sessionContext="+sessionContext+", reset
counter to 1 in session");
 }
 
 public void destroy(ServiceContext serviceContext) {
  printMessage("destroy()", "begin");
  
  SessionContext sessionContext = getSessionContext();
  sessionContext.getProperties().remove(PROP_COUNTER);
  
  printMessage("destroy()", "sessionContext="+sessionContext+", remove
counter from session");
 }
 
 private SessionContext getSessionContext() {
  MessageContext messageContext = MessageContext
.getCurrentMessageContext();
  SessionContext sessionContext = messageContext.getSessionContext();
 
  return sessionContext;
 } 
 
 private void printMessage(String method, String message) {
  System.out.println(method+"::"+message);
 }
}
 

 
 
 services.xml =










http://www.w3.org/2004/08/wsdl/in-out";
class="com.compuware.axis2.gen.MySessionServiceMessageReceiverInOut"/>



com.compuware.axis2.gen.MySessionServiceSkeleton

http://www.w3.org/2004/08/wsdl/in-out";>

urn:plusone

http://axis2.compuware.com/MySessionServicePortType
/plusoneResponse







 
 
 
 MySessionService.wsdl ==
http://axis2.compuware.com";
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/";
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/";
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/";
xmlns:ns="http://axis2.compuware.com/xsd";
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
targetNamespace="http://axis2.compuware.com";>http://www.w3.org/2001/XMLSchema";
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://axis2.compuware.com/xsd";>















http://www.w3.org/2006/05/addressing