1 Reply Latest reply on Oct 20, 2009 3:12 PM by gweiske

    (SOAP) WS using cookie

    gweiske

      With CXF, I would like to create a (SOAP) WS that uses cookies - but I cannot get it to work. It appears that I need to provide some Jetty configuration in a cxf.xml file. Below is what I used, but that does not seem sufficient. When I send a request to the service, I expect the response to have a set-cookie header, but there is none. I was shown an example that handles cookies explicitly, something like the code below. However, I get

      org.apache.cxf.interceptor.Fault: No SessionHandler or SessionManager

      when trying to get the session from the request. Do I have to get (or set) one of these? Where do I get them from? I googled cxf and cookies and all the question were about the client, so I assume the server side is straight forward. What I am missing?

       

      Many thanks

       

      Gregor

       

          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");

              }