Results 1 to 6 of 6

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

  1. #1
    Join Date
    Oct 2012
    Posts
    4

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

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Oct 2012
    Posts
    4

    Default

    yes. Any idea on how to handle the session?

  4. #4
    Join Date
    Oct 2012
    Posts
    4

    Default

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

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #6
    Join Date
    Oct 2012
    Posts
    4

    Default

    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?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •