Here is my service configuration : <serviceGroup>
<!-- Sample --> <service name="sample" scope="soapsession"> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> </messageReceivers> <parameter name="ServiceClass" locked="false">fr.axis2ws.wsmobile.SampleService</parameter> <operation name="getResult" mep="http://www.w3.org/2004/08/wsdl/in-out"> <actionMapping>urn:getResult</actionMapping> </operation> </service> <!-- Other services --> ... </serviceGroup> Here is my service source code : package fr.axis2ws.wsmobile; /* Various imports */ public abstract class SampleService { private static Logger logger = Logger.getLogger(SampleService.class); private Member member = null; private String sessionId = null; /** * @param sc * @throws SampleInitException */ public void init (ServiceContext sc) throws SampleInitException { try { if (this.member == null) { if (this.idSession == null) { this.idSession = sc.getServiceGroupContext().getId(); } this.member = (Member)sc.getServiceGroupContext().getProperty(Const.MEMBER); if (this.member == null) { this.member = new Member(); sc.getServiceGroupContext().setProperty(Const.MEMBER, this.member); } } } catch (Throwable t) { logger.error("Init error", t); throw new SampleInitException("Init error", t); } } /** * @param sc * @throws SampleInitException */ public void destroy (ServiceContext sc) throws SampleInitException { logger.info("Destroy"); } public SampleResponse getResult (long param) throws WsMobNoeudException { try { SampleResponse response; /* Some code */ response = new SampleResponse(SampleResponse.SUCCESS, this.sessionId); return response; } catch (Throwable t) { logger.error("Failure", t); throw new SampleException("Failure", t); } } } And here is the source code for creating a response object : /* Various imports */ public class SampleResponse { public static int VOID = -1; public static int SUCCESS = 0; public static int FAILURE = 1; protected int errorCode = VOID; public SampleResponse (int errorCode, String sessionId) { this.errorCode = errorCode; this.sessionId = sessionId; } public String getSessionId () { return this.sessionId; } public int getErrorCode () { return this.errorCode; } } Thank you. Best regards, Benoît Smith Selon Martin Gainty <[EMAIL PROTECTED]>: > when unspecified the default scope is session scope so taking a quick look > at the code to generate the id for your Session > GetResult gr = new GetResult(); > gr.setParam(-1); > GetResultResponse reponse = stub.getResult(gr); > idSession = reponse.get_return().getIdSession(); > > there appears to be some malady in either > GetResultResponse > OR > GetResult > > can you display the contents of the classes to group? > > Thanks > Martin-- > > ----- Original Message ----- > From: "Michele Mazzucco" <[EMAIL PROTECTED]> > To: <axis-user@ws.apache.org> > Sent: Monday, February 18, 2008 4:36 AM > Subject: Re: Axis2 session management (yes, I know that subject is a bit > worn-out) > > > Benoît, > > > my guess is that the service must be configured in session scope. > > > Michele > > On 18 Feb 2008, at 08:38, Benoît Smith wrote: > > > Greetings, > > > > I'm a clear newbie to Axis2, and I'm aware that the question I'm > > asking has > > already been asked in many forms before. The thing is, none of the > > solutions > > appeared to solve my specific problem. So I'll try to be as > > accurate as > > possible. > > > > My objectives : > > Run some Axis2 web services on a Tomcat servlet container, and > > access them with > > a *remote* client, using session management. > > > > Server-side configuration : > > - Axis2 1.2 (for compatibility reasons, I have to stick with 1.2), > > installed as > > a component on a Tomcat 6.0.14 servlet container. > > - axis2.xml configured by default. The Addressing module seems well > > engaged. > > - The SampleService I wrote includes a 'sessionId' value in its > > responses. That > > value contains the result for sc.getServiceGroupContext().getId(), > > which is - I > > think - the value I should keep for session management. > > - I can access the autogenerated WSDL through an URL like: > > http://www.mydomain.com:8080/axis2/sampleService?wsdl > > > > Client-side configuration : > > - A standalone client based on Axis2 1.2. > > - Stubs are generated with the following command : > > WSDL2Java.main( > > new String[] { > > "-uri", "http://www.mydomain.com:8080/axis2/sampleService?wsdl", > > "-o", "/some/output/path", > > "-p", "fr.axis2ws.test.stubs" > > } > > ); > > - The test client sends ten requests to the service. At each loop, > > it tries to > > retrieve the 'sessionId' value from the response, then reinsert it > > in the header > > of the next request. Here is the source code : > > public static void main (String args[]) throws Exception { > > String idSession = null; > > for (int i = 0; i < 10; i++) { > > SampleServicesampleServiceHttpportStub stub = new > > SampleServicesampleServiceHttpportStub(); > > stub._getServiceClient().getOptions().setManageSession > > (true); > > > > stub._getServiceClient().getOptions().setProperty > > (AddressingConstants.WS_ADDRESSING_VERSION, > > AddressingConstants.Final.WSA_NAMESPACE); > > stub._getServiceClient().engageModule > > (Constants.MODULE_ADDRESSING); > > if (idSession != null) { > > stub._getServiceClient() > > .setTargetEPR(new > > EndpointReference("http://www.mydomain.com:8080/axis2/ > > sampleService")); > > stub._getServiceClient() > > .addStringHeader( > > new QName( > > Constants.AXIS2_NAMESPACE_URI > > , Constants.SERVICE_GROUP_ID > > , Constants.AXIS2_NAMESPACE_PREFIX > > ) > > , idSession > > ); > > } > > GetResult gr = new GetResult(); > > gr.setParam(-1); > > GetResultResponse reponse = stub.getResult(gr); > > idSession = reponse.get_return().getIdSession(); > > } > > } > > > > I trust you probably guessed the result already - the tests failed. > > Somewhere > > along the way, the 'sessionId' value is lost, so the service > > returns a new one, > > which makes session management impossible. > > > > I'm pretty sure I'm missing something, but so far, I failed to see > > what. Any > > help will be greatly appreciated. Thank you ! > > > > Best regards, > > Benoît Smith > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]