Search code examples
springspring-bootspring-ws

Spring WS Maintaining Sessions


I have published web service and client using spring boot and spring ws. How can I manage sessions in Spring WS? In JAX-WS in request context there is a property for that: BindingProvider.SESSION_MAINTAIN_PROPERTY I have tried to use session scopes from Spring but with no results...


Solution

  • You can get access to the HTTP session by using the TransportContext:

    TransportContext context = TransportContextHolder.getTransportContext();
    HttpServletConnection connection = (HttpServletConnection)context.getConnection();
    HttpServletRequest request = connection.getHttpServletRequest();
    HttpSession session = request.getSession();
    

    But like M.Deinum said, Web services typically try to be stateless.