use of javax.xml.ws.handler.MessageContext in project cxf by apache.
the class GreeterSessionImpl method greetMe.
// greetMe will use session to return last called name
public String greetMe(String me) {
LOG.info("Executing operation greetMe");
LOG.info("Message received: " + me);
MessageContext mc = context.getMessageContext();
HttpServletRequest req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
Cookie[] cookies = req.getCookies();
String val = "";
if (cookies != null) {
for (Cookie cookie : cookies) {
val += ";" + cookie.getName() + "=" + cookie.getValue();
}
}
HttpSession session = req.getSession();
// Get a session property "counter" from context
if (session == null) {
throw new WebServiceException("No session in WebServiceContext");
}
String name = (String) session.getAttribute("name");
if (name == null) {
name = me;
LOG.info("Starting the Session");
}
session.setAttribute("name", me);
return "Hello " + name + val;
}
Aggregations