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 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 ===================== > > > <!-- This file was auto-generated from WSDL --> > > <!-- by the Apache Axis2 version: #axisVersion# #today# --> > > <serviceGroup> > > <service name="MySessionService" scope="transportsession"> > > <messageReceivers> > > <messageReceiver > mep="http://www.w3.org/2004/08/wsdl/in-out" > class="com.compuware.axis2.gen.MySessionServiceMessageReceiverInOut"/> > > </messageReceivers> > > <parameter locked="false" > name="ServiceClass">com.compuware.axis2.gen.MySessionServiceSkeleton</ > parameter> > > <operation name="plusone" > mep="http://www.w3.org/2004/08/wsdl/in-out"> > > <actionMapping>urn:plusone</actionMapping> > > <outputActionMapping>http://axis2.compuware.com/MySessionServicePortTy > pe/plusoneResponse</outputActionMapping> > > </operation> > > </service> > > </serviceGroup> > > > > ============ MySessionService.wsdl ====================== > > > <wsdl:definitions xmlns:axis2="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"><wsdl:types><xs:schema > xmlns:xs="http://www.w3.org/2001/XMLSchema" > attributeFormDefault="qualified" > elementFormDefault="qualified" > targetNamespace="http://axis2.compuware.com/xsd"> > > <xs:element name="plusoneResponse"> > > <xs:complexType> > > <xs:sequence> > > <xs:element name="return" nillable="true" type="xs:int" /> > > </xs:sequence> > > </xs:complexType> > > </xs:element> > > </xs:schema></wsdl:types><wsdl:message > name="plusoneMessage" /><wsdl:message > name="plusoneResponseMessage"><wsdl:part name="part1" > element="ns:plusoneResponse" /></wsdl:message><wsdl:portType > name="MySessionServicePortType"><wsdl:operation > name="plusone"><wsdl:input > xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" > message="axis2:plusoneMessage" wsaw:Action="urn:plusone" > /><wsdl:output xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" > message="axis2:plusoneResponseMessage" > wsaw:Action="http://axis2.compuware.com/MySessionServicePortType/plusone Response" > /></wsdl:operation></wsdl:portType><wsdl:binding > name="MySessionServiceSOAP11Binding" > type="axis2:MySessionServicePortType"><soap:binding > transport="http://schemas.xmlsoap.org/soap/http" > style="document" /><wsdl:operation name="plusone"><soap:operation > soapAction="urn:plusone" style="document" /><wsdl:input><soap:body > use="literal" /></wsdl:input><wsdl:output><soap:body > use="literal" > /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:binding > name="MySessionServiceSOAP12Binding" > type="axis2:MySessionServicePortType"><soap12:binding > transport="http://schemas.xmlsoap.org/soap/http" > style="document" /><wsdl:operation > name="plusone"><soap12:operation soapAction="urn:plusone" > style="document" /><wsdl:input><soap12:body use="literal" > /></wsdl:input><wsdl:output><soap12:body use="literal" > /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service > name="MySessionService"><wsdl:port > name="MySessionServiceSOAP11port_http" > binding="axis2:MySessionServiceSOAP11Binding"><soap:address > location="http://localhost:8080/axis2/services/MySessionService" > /></wsdl:port><wsdl:port > name="MySessionServiceSOAP12port_http" > binding="axis2:MySessionServiceSOAP12Binding"><soap12:address > location="http://localhost:8080/axis2/services/MySessionService" > /></wsdl:port></wsdl:service></wsdl:definitions> > > > > > > > > > > The contents of this e-mail are intended for the named addressee only. > It contains information that may be confidential. Unless you are the > named addressee or an authorized designee, you may not copy or use it, > or disclose it to anyone else. If you received it in error please > notify us immediately and then destroy it. -- Davanum Srinivas :: http://wso2.org/ :: Oxygen for Web Services Developers --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]