scope=transportsession, new SessionContext instance for each request
Hello, I am trying to work out a very simple example with scope=transportsession. The purpose of this exercise is to save an attribute on the session for use when the server receives several requests from the same client. The following code returns a different SessionContext instance every time the service is called. Thus when I use session.getProperty(), null is always returned even if I have called setProperty() in a previous request. public class EchoMessageReceiverInOut extends org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver{ private static final String ATTR_KEY=CUSTOM_ATTRIBUTE; public void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext, org.apache.axis2.context.MessageContext newMsgContext) throws org.apache.axis2.AxisFault{ try { SessionContext sessionContext = msgContext.getSessionContext(); String id=null; if (sessionContext!=null) { id=(String)sessionContext.getProperty(ATTR_KEY); if (id==null){ id=85; sessionContext.setProperty(ATTR_KEY, id); } } // get the implementation class for the Web Service Object obj = getTheImplementationObject(msgContext); Is there any other configuration that I am required to add, possibly on the client side? Is there another (better) way to save an attribute for the session? I'm using axis2-1.3 (latest release) and tomcat 5.5. This is what my service.xml looks like: serviceGroup service scope=transportsession name=Echo messageReceivers messageReceiver mep=http://www.w3.org/ns/wsdl/in-out; class=org.example.www.echo.EchoMessageReceiverInOut/ /messageReceivers parameter name=ServiceClassorg.example.www.echo.EchoSkeleton/parameter ... Thanks for your help, Kevin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: scope=transportsession, new SessionContext instance for each request
Hi Kevin , Do you sure you send the correct cookies Thank you! -Deepal Hello, I am trying to work out a very simple example with scope=transportsession. The purpose of this exercise is to save an attribute on the session for use when the server receives several requests from the same client. The following code returns a different SessionContext instance every time the service is called. Thus when I use session.getProperty(), null is always returned even if I have called setProperty() in a previous request. public class EchoMessageReceiverInOut extends org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver{ private static final String ATTR_KEY=CUSTOM_ATTRIBUTE; public void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext, org.apache.axis2.context.MessageContext newMsgContext) throws org.apache.axis2.AxisFault{ try { SessionContext sessionContext = msgContext.getSessionContext(); String id=null; if (sessionContext!=null) { id=(String)sessionContext.getProperty(ATTR_KEY); if (id==null){ id=85; sessionContext.setProperty(ATTR_KEY, id); } } // get the implementation class for the Web Service Object obj = getTheImplementationObject(msgContext); Is there any other configuration that I am required to add, possibly on the client side? Is there another (better) way to save an attribute for the session? I'm using axis2-1.3 (latest release) and tomcat 5.5. This is what my service.xml looks like: serviceGroup service scope=transportsession name=Echo messageReceivers messageReceiver mep=http://www.w3.org/ns/wsdl/in-out; class=org.example.www.echo.EchoMessageReceiverInOut/ /messageReceivers parameter name=ServiceClassorg.example.www.echo.EchoSkeleton/parameter ... Thanks for your help, Kevin - 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]
Re: scope=transportsession, new SessionContext instance for each request
Good question. Looks like the problem was on the client side. I was using the following to setup the client: Options options = new Options(); options.setAction(command); options.setTo(new EndpointReference(endpoint)); serviceClient.setOptions(options); Adding the setMangedSession() call as follows fixes the problem. Options options = new Options(); options.setAction(command); options.setTo(new EndpointReference(endpoint)); options.setManageSession(true); serviceClient.setOptions(options); Thanks again! On Thu, Mar 20, 2008 at 12:43 PM, Deepal jayasinghe [EMAIL PROTECTED] wrote: Hi Kevin , Do you sure you send the correct cookies Thank you! -Deepal Hello, I am trying to work out a very simple example with scope=transportsession. The purpose of this exercise is to save an attribute on the session for use when the server receives several requests from the same client. The following code returns a different SessionContext instance every time the service is called. Thus when I use session.getProperty(), null is always returned even if I have called setProperty() in a previous request. public class EchoMessageReceiverInOut extends org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver{ private static final String ATTR_KEY=CUSTOM_ATTRIBUTE; public void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext, org.apache.axis2.context.MessageContext newMsgContext) throws org.apache.axis2.AxisFault{ try { SessionContext sessionContext = msgContext.getSessionContext(); String id=null; if (sessionContext!=null) { id=(String)sessionContext.getProperty(ATTR_KEY); if (id==null){ id=85; sessionContext.setProperty(ATTR_KEY, id); } } // get the implementation class for the Web Service Object obj = getTheImplementationObject(msgContext); Is there any other configuration that I am required to add, possibly on the client side? Is there another (better) way to save an attribute for the session? I'm using axis2-1.3 (latest release) and tomcat 5.5. This is what my service.xml looks like: serviceGroup service scope=transportsession name=Echo messageReceivers messageReceiver mep=http://www.w3.org/ns/wsdl/in-out; class=org.example.www.echo.EchoMessageReceiverInOut/ /messageReceivers parameter name=ServiceClassorg.example.www.echo.EchoSkeleton/parameter ... Thanks for your help, Kevin - 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]