سؤال

I am trying to figure out how to implement session management in wso2 esb.So i have written a class mediator which generates session_ID that i want to store.For storing the session id I am using following code as:

org.apache.axis2.context.ServiceContext serviceContext = org.apache.axis2.context.MessageContext
            .getCurrentMessageContext().getServiceContext();
serviceContext.setProperty("SessionIDGlobal", uuid);

But while running it in my esb's proxy it throws null pointer exception at getCurrentMessageContext part.I have followed another approach where-in i am storing the sessionID in property mediator and tried to get its value but when i click postRequest operation after generateSessionID operation from try-it. all the property gets reset and my sessionID property gives me null value. What should i do to rectify this problem? Is there any alternate way?

هل كانت مفيدة؟

المحلول

You have to create servicecontext like this;

ConfigurationContext cfgCtx =(((Axis2MessageContext) synCtx).getAxis2MessageContext(). getConfigurationContext();

cfgCtx.getOperationContext().getServiceContext();

نصائح أخرى

You should store in the Message context but you have stored in the service Context. please refer this to understand how you can set the properties at different scopes. Synapase (default), Axis2, Transport etc.

Please refer this blog post for complete details. http://blog.facilelogin.com/2011/02/wso2-esb-property-mediator-different.html

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top