The issue we having now is, it seems that whenever there is a request sending to a Spring WS framework, a session will be created by the framework to store the request and response objects so that it can be delegate to/from the endpoint object that we built. This is a piece of source code where request object set into a session.
request.getSession().setAttribute("pickupAddressFo rBookingRequestObject", pickupAddressForBookingRequestObject );
It is still called stateless web service because the session is not persisted or reuse for other requests. New session is always created for new request in this case. Please find below scenario before and after implement session invalidate() method.
As you see in figure 1, current session number increment by one for every request and response sending receiving to Spring WS.
Spring WS Session.JPG
Captured logs shows when sessions get created for request and response object.
Request object session
ESPHttpSessionAttributeListener Attribute added Session Id: cQfJQL1fCpVySTrl6PTTXn1cvpQBQ5MCM9bykyh1hlsd0qL1NP 24!-172751608!1351136767530
ESPHttpSessionAttributeListener Attribute added: accountValidationRequestObject : {billCountry=mx, webServiceURL=, collaborationId=12334, accountNo=980100903}
Respose object session
ESPHttpSessionAttributeListener Attribute added Session Id: cQfJQL1fCpVySTrl6PTTXn1cvpQBQ5MCM9bykyh1hlsd0qL1NP 24!-172751608!1351136767530
ESPHttpSessionAttributeListener Attribute added: accountValidationResponseObject:xxx.xxx.xxx.ws.Val idateAccountResponse@533045a7
ValidateAccountEndpoint.java
Code:@Endpoint public class ValidateAccountEndpoint { private static final String ENDPOINT_NAME = "ValidateAccountEndpoint"; // The namespace of both request and response as declared in the XSD file public static final String NAMESPACE_URI = "http://www.test.com/ws/schema/va"; // The local name of the expected request. public static final String REQUEST_LOCAL_NAME = "ValidateAccountRequest"; @SuppressWarnings("unchecked") @PayloadRoot(localPart = REQUEST_LOCAL_NAME, namespace = NAMESPACE_URI) @ResponsePayload public ValidateAccountResponse retrieveInvoiceInfo(@RequestPayload ValidateAccountRequest accountValidationRequest) { . . . . }
Is there any configuration or other better solution to prevent Spring Framework from creating session of request and response object?


Reply With Quote
