1 Reply Latest reply on Oct 24, 2008 6:53 AM by agori

    Sharing HttpSession between multiple webservices

    agori

      Actually we have two or three webservices in the same EAR.
      They are also stateful webservices, because thought they are marked as @Statless, they should mantain some data between client calls using HttpSession.

      First question: if we use HttpSession as data container, is possible to share this session among multiple webservices? We know about the SESSION_MANTAIN property, but it works only in case of a single WS.
      What should I do at client side?

      Second question: we are using EJB Session bean. Is possible to share the HttpSession between two or more EAR or JVM? I mean, if we deploy our WS in different machines, how is possible to make them see the same HTTP session?

        • 1. Re: Sharing HttpSession between multiple webservices
          agori

          I found that this solution works:

          MyService client1 = (MyService) service.getPort(...);
          BindingProvider prov1 = (BindingProvider) client1;
          Map<String, Object> request = prov1.getRequestContext();
          request.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
          client1.login("agori", "sfsfaf");
          
          Object cookieJar = request.get("com.sun.xml.internal.ws.client.http.CookieJar");
          
          MyService2 client2 = service.getPort('...');
          BindingProvider prov2 = (BindingProvider) client2;
          request = prov2.getRequestContext();
          request.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
          request.put("com.sun.xml.internal.ws.client.http.CookieJar", cookieJar);
          
          client2.myMethod();