You can modify the session data in the rwsf::CallInfo object at any point along the message handler chain. Typically, these modifications would be made in the server implementation, but you could also create a message handler specifically for manipulating the session data. For information on creating a message handler, see Chapter 14, "SOAP Message Handler SDK."
The code below shows how you might modify the session data in the rwsf::CallInfo object.
rwsf::Attribute httpSession = callInfo.get("rwsf:Session"); //1 rwsf::HttpSession session; //2 httpSession >> session; //3 std::string sessionID = session.getId(); //4 // processing keyed to the session ID int priority = 2; //5 rwsf::Attribute priorityAttr; //6 priorityAttr << priority; //7 session.setAttribute("priority", priorityAttr); //8
//1 | Retrieve the rwsf::Attribute containing the rwsf::HttpSession. |
//2 | Create a rwsf::HttpSession object. |
//3 | Shift the contents of httpSession into the rwsf::HttpSession object. |
//4 | Retrieve the session ID. Use the session ID as the basis for session-specific processing. |
//5 | Create a data object called priority. |
//6 | Create a rwsf::Attribute instance for the priority attribute. |
//7 | Shift the priority value into priorityAttr. |
//8 | Add the attribute to the rwsf::HttpSession object. |
This is all you need to do. The rwsf::HttpSession object passed around in the rwsf::CallInfo object is a handle to a body representing the session data held in the HydraExpress Agent. By making calls on the handle, you are directly changing the session data that will be returned to the client.
Note that rwsf::CallInfo has an interface that allows you to add and modify SOAP and transport header elements. This general-purpose mechanism for passing metadata between client and server is an alternative way to exchange session data. For more information, see Chapter 15, "SOAP and Transport Headers."
© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.