Announcement Announcement Module
Collapse
No announcement yet.
Issue - session created whenever there is a request sending to a Spring WS framework Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue - session created whenever there is a request sending to a Spring WS framework

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


    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?
    Attached Files

  • #2
    So you are setting stuff on the session and don't expect a session to be created.. Not sure if that is going to work...

    Comment


    • #3
      yes. Any idea on how to handle the session?

      Comment


      • #4
        Any useful web sites i can refer converting stateful session to stateless?

        Comment


        • #5
          DOn't put stuff on the session... I still don't get your problem as mentioned before.. You are putting stuff in the http session and for some reason you don't want that, then don't store stuff in the session.

          Comment


          • #6
            servlet.java
            request.getSession().setAttribute("pickupAddressFo rBookingRequestObject", pickupAddressForBookingRequestObject );


            AccountValidate.jsp

            if( request.getSession().getAttribute("accountValidati onRequestObject") != null &&
            request.getSession().getAttribute("accountValidati onResponseObject") != null ){

            // Request
            HashMap<String,String> validateAccountRequest = ( HashMap<String,String> )request.getSession().getAttribute("accountValidat ionRequestObject");
            if( validateAccountRequest.get("webServiceURL") != null && !validateAccountRequest.get("webServiceURL").equal sIgnoreCase("") ){
            webServiceURL = validateAccountRequest.get("webServiceURL");
            }

            // Response
            ValidateAccountResponse validateAccountResponse = (ValidateAccountResponse)request.getSession().getA ttribute("accountValidationResponseObject");
            collaborationId = validateAccountResponse.getCollaborationId();
            accountNo = validateAccountResponse.getAccountNumber();
            billCountry = validateAccountResponse.getBillCountry();
            pickupCountry = validateAccountResponse.getBillCountry();
            }

            i set values into pickupAddressForBookingRequestObject session object so that values will be populated from first JSP page into second JSP page. New session is always created for new request in this case and not persisted or reuse for other requests. I understand web service should be stateless.
            But in this scenario, any suggestion on how to prevent Spring WS framework from counting created session for each request object?

            Comment

            Working...
            X