mariusz-s
mariusz-s

Reputation: 1766

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...

Upvotes: 0

Views: 1001

Answers (1)

Arjen Poutsma
Arjen Poutsma

Reputation: 1256

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.

Upvotes: 1

Related Questions