Hi, You can have a Map member field in the Mediator class with each session to be identified by the map key and the data (or data collection) you need to store as the value. For the session key you can find a unique id or something that comes in the message. So in the mediator you can store the values against that id key.
If there is no unique ID in the message you can generate a session id and put it in the map. For the message that is passing through the mediator you can setProperty() in Synapse messageContext the generated session ID. In the return path in the response you can get that generated ID by Synapse messageContext getProperty() and set it to the response message going through the out path. This way in message can be correlated with the outgoing message. That ID can be sent with the out going message. Then the session ID can be again sent by the client for the next request message. If you are using cookie headers (Cookie, Set-Cookie) for sending and returning session ID then it can be located in the headers map in the axis2 message context. String cookieString = null; // cookieString org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext(); Object headers = axis2MessageContext.getProperty( org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (headers != null && headers instanceof Map) { Map headersMap = (Map) headers; // for all headers cookieString = (String) headersMap.get(HEADER_COOKIE); } Upul On Jan 18, 2008 8:13 AM, Venkatesan, Kumaran < [EMAIL PROTECTED]> wrote: > Paul, > > The requirement is exactly what you told in the previous mail. > > *2) You want Synapse to issue a cookie and act as the Session Manager* > > *and then you will store some information at Synapse that you will* > > *Validate** the next time the client sends a message.*** > > How the above could be achieved with Synapse. > > One more doubt from my side. If i deploy the synapse installable (WAR > format) on a web container(Tomcat provider), the application running in > two different http ports as below. > > HttpCoreNIOListener HTTP Listener starting on port : 8080 > > INFO: Starting Coyote HTTP/1.1 on http-8081 > > In which port I need to send request for a web service call. > > With Regards > > Kumaran > > -----Original Message----- > From: Paul Fremantle [mailto:[EMAIL PROTECTED] <[EMAIL PROTECTED]>] > Sent: Wednesday, January 16, 2008 5:05 PM > To: synapse-dev@ws.apache.org > Cc: [EMAIL PROTECTED] > Subject: Re: Custom mediator - Not able to get HttpServletRequest > > Kumaran > > Thanks. Yes the details confirm the fact you are using the HTTP NIO > > connector which doesn't use servlets. > > When you say you wish to validate the session can you explain what you > mean? > > I guess there are two possibilities I can think of (maybe there are > others) > > 1) The actual target service is using sessions and you want to > > validate that the client is sending back a cookie issued by the > > service > > 2) You want Synapse to issue a cookie and act as the Session Manager > > and then you will store some information at Synapse that you will > > validate the next time the client sends a message. > > I'm not clear which of these behaviours you are looking for. I'm sure > > we can support both :) Its just one might take more work than the > > other. > > Paul > > On Jan 16, 2008 6:45 AM, Venkatesan, Kumaran > > <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > The requirement is to have Stateful mediation configuration. Each > service > > > request from the client will be passed through the > > > > > > Synapse and need to do basic verification like Session checking and > > > Funcational Access Profile checking(FAP) before the request > > > > > > sent to the EPR's deployed on different hosts. > > > > > > > > > > > > Have utilized the synapse example (sample_380.xml) to test this and used > the > > > HTTP port 8080 > > > > > > > > > > > > <sequence name="main" onError="fault"> > > > > > > <class name="samples.mediators.SessionMediator"/> > > > > > > > > > > > > 2008-01-16 14:43:38,407 [172.18.48.209-SGNHTY3H1S] [main] INFO > > > HttpCoreNIOListener HTTPS Listener starting on port : 8443 > > > > > > 2008-01-16 14:43:38,407 [172.18.48.209-SGNHTY3H1S] [main] INFO > > > ServerManager Starting transport https on port 8443 > > > > > > 2008-01-16 14:43:38,469 [172.18.48.209-SGNHTY3H1S] [main] DEBUG > > > HttpCoreNIOListener Starting Listener... > > > > > > 2008-01-16 14:43:38,485 [172.18.48.209-SGNHTY3H1S] [main] INFO > > > HttpCoreNIOListener HTTP Listener starting on port : 8080 > > > > > > 2008-01-16 14:43:38,485 [172.18.48.209-SGNHTY3H1S] [main] INFO > > > ServerManager Starting transport http on port 8080 > > > > > > > > > > > > > > > With Regards > > > > > > Kumaran > > > > > > ________________________________ > > > > > > > > > From: Asankha C. Perera [mailto:[EMAIL PROTECTED] <[EMAIL PROTECTED]>] > > > Sent: Wednesday, January 16, 2008 12:24 PM > > > > > > To: synapse-dev@ws.apache.org > > > Cc: Venkatesan, Kumaran > > > Subject: Re: Custom mediator - Not able to get HttpServletRequest > > > > > > > > > > > > > > > > > > Hi Kumaran > > > > > > I notice that you have not yet subscribed to the synapse-dev mailing > list.. > > > As per the page at http://ws.apache.org/synapse/mail-lists.html, you > first > > > need to "subscribe" to the mailing list by sending an email to > > > "[EMAIL PROTECTED]", and you will then get membership > to > > > post to this list, and will receive any replies to your questions and > other > > > discussion items taking place. > > > > > > As you may notice from the mail archives, I approved your mail to the > > > synapse-dev as the moderator, and myself and Paul have replied to it > already > > > (See http://marc.info/?l=synapse-dev&m=120040701518927&w=2) > > > > > > Hope to see you joining the mailing list soon, and we welcome you to > the > > > Synapse community and look forward to helping you solve your issues > > > > > > asankha > > > > > > Venkatesan, Kumaran wrote: > > > > > > Please any updates on this. > > > > > > The requirement is to use the custom mediators to validate the session > > > before sending it to the service end points(EPR). > > > > > > _____________________________________________ > > > From: Venkatesan, Kumaran > > > Sent: Tuesday, January 15, 2008 2:25 PM > > > To: 'synapse-dev@ws.apache.org' > > > Subject: Custom mediator - Not able to get HttpServletRequest > > > > > > Hi, > > > > > > We have planned to use the synapse as mediation layer for our service > based > > > architecture. > > > > > > There is a requirement to get the handle of the HttpServletRequest > object > > > under the custom mediator(SessionMediator.java) to tackle the session > > > management. > > > > > > Have tried the below but giving null value for the "HttpServletRequest" > > > object. > > > > > > public class SessionMediator implements Mediator { > > > > > > private static final Log log = > > > LogFactory.getLog(DiscountQuoteMediator.class); > > > > > > public SessionMediator(){} > > > > > > public boolean mediate(MessageContext mc) { > > > > > > > > > > > > Axis2MessageContext axis2mc = (Axis2MessageContext)mc; > > > > > > org.apache.axis2.context.MessageContext axis2MessageCtx = > > > axis2mc.getAxis2MessageContext(); > > > > > > > > > > > > HttpServletRequest request = > > > (HttpServletRequest)axis2MessageCtx.getProperty( > HTTPConstants.MC_HTTP_SERVLETREQUEST); > > > > > > Pls help how to get the "HttpServletRequest" > > > > > > With Regards > > > > > > Kumaran This email is confidential. If you are not the addressee tell > the > > > sender immediately and destroy this email > > > without using, sending or storing it. Emails are not secure and may > suffer > > > errors, viruses, delay, > > > interception and amendment. Standard Chartered PLC and subsidiaries > > > ("SCGroup") do not accept liability for > > > damage caused by this email and may monitor email traffic. > > > > > > > > > This email is confidential. If you are not the addressee tell the > sender > > > immediately and destroy this email > > > without using, sending or storing it. Emails are not secure and may > suffer > > > errors, viruses, delay, > > > interception and amendment. Standard Chartered PLC and subsidiaries > > > ("SCGroup") do not accept liability for > > > damage caused by this email and may monitor email traffic. > > > > > > > > > -- > > Paul Fremantle > > Co-Founder and VP of Technical Sales, WSO2 > > OASIS WS-RX TC Co-chair > > blog: http://pzf.fremantle.org > > [EMAIL PROTECTED] > > "Oxygenating the Web Service Platform", www.wso2.com > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > This email is confidential. If you are not the addressee tell the sender > immediately and destroy this email > without using, sending or storing it. Emails are not secure and may suffer > errors, viruses, delay, > interception and amendment. Standard Chartered PLC and subsidiaries > ("SCGroup") do not accept liability for > damage caused by this email and may monitor email traffic. > >