Service Virtualization

  • 1.  Error after rest step when virtual responder step is invoked.

    Posted Apr 17, 2018 10:28 AM

    Hi All,

     

    I have below issue when in the virtual responder step after a proper response is returned by REST step.

     

    Problem statement : Rest step triggers request to Live application.Live applicaion responds with a response.This response is then passed to virtual responder and then finally posted to Listener.

     

    Issue : Proper response is retuerned by Live application.But when Virtual responder is returning the the response, there is some error.

     

    Error description : 

    ============================================================================
    | java.lang.ArrayIndexOutOfBoundsException
    ============================================================================
    | Step: Virtual HTTPS Responder - Live
    ----------------------------------------------------------------------------
    | Trapped Exception: null
    | Trapped Message: java.lang.ArrayIndexOutOfBoundsException
    ----------------------------------------------------------------------------
    STACK TRACE
    java.lang.ArrayIndexOutOfBoundsException
    ============================================================================

     



  • 2.  Re: Error after rest step when virtual responder step is invoked.

    Posted Apr 18, 2018 07:55 AM

    Can you post a picture of the Responder Step configuration?

    I am curious to see what property the model is responding from.

    Responder steps send responses from a property of type List (e.g., lisa_vse_response is a List object holding a list of transient response objects). The accessor methods in the Responder step  

    a) use indexing to retrieve and send each response in the List (HTTP only sends the first or 0 response) and

    b) expect the object at occurrence 0 to be an object of type Transient Response. 



  • 3.  Re: Error after rest step when virtual responder step is invoked.

    Posted Apr 18, 2018 09:43 AM

    Hi Joel,

     

    We are using property "Final_Response"in responder step, which is captured in the rest step.

     

    "Final_Response" is the store step response from the rest step.Am passing this to responder step.

     

    Note : i tried passing "lisa.vse.response" in responder step, but the response saved in this property is from Java script step.Rest step transient response is not saved into "lisa.vse.response".So we are not getting desired response from rest step using "lisa.vse.response".

     

     



  • 4.  Re: Error after rest step when virtual responder step is invoked.

    Posted Apr 18, 2018 11:16 AM

    Since your flow appears to have gone through the VS Image Selection step, an initialized lisa_vse_response list should be available so we should be able to reuse that response. 

     

    As a test, please try the following:

    1) Allow your POST_LIVE step to fire and allow the filter to create the Final_Response property

    2) Add a JSR-223 step between the POST_LIVE and Virtual HTTPS Responder-Live step (you could do this as a Scripted Assertion in the REST Step, but a JSR version is shown here).

    In the JSRstep, add logic to marshal the Final_Response property value into the VSE response list. Code fragment is:

    lisa_vse_response.get(0).setBody( testExec.getStateString("Final_Response", "RESPONSE NOT FOUND") );

    return "Response Has Been Set";

    3) After the JSR Step, allow the next step to be the Responder Step. 

    4) Ensure the Responder Step is using the List property name of:  lisa.vse.response rather than Final_Response.

     

    Give this a try and let us know if you still have issues.

     

    Note: The above code fragment does not set the HTTP-Response-Code value. The HTTP Response Code in the lisa_vse_response at occur 0 will be the value returned by the VS Image Selection Step. If you need the HTTP Response Code from the REST call, you will need to filter POST_LIVE's HTTP Response Code and set it in the lisa_vse_response's Meta Data property ("HTTP-Response-Code") in the POST_LIVE and JSR steps, respectively. 



  • 5.  Re: Error after rest step when virtual responder step is invoked.

    Posted Apr 18, 2018 11:49 AM

    I tried the above approach you suggested.Am getting error in JSR step now.

     

    Just for Info, below is the response returned by the Live Server.(POST LIVE step)

     

     

    I want the above response to be passed to Listener



  • 6.  Re: Error after rest step when virtual responder step is invoked.
    Best Answer

    Posted Apr 18, 2018 01:11 PM

    The JSR code fragment above is Beanshell not Javascript so please check that.

    It is possible I injected a typo. But, I have seen Microsoft quotes (which are not the same hex characters as ASCII quotes) throw exceptions. And, I have seen misleading exceptions caused by errors elsewhere in the script. I doubt that getStateString(<String>, <String>) is an issue, but you can also try testExec.getStateValue("<thePropertyName>"). 

    A JSR step can return pretty much anything including return true -- so changing to return true is also an option.

     

    The Java Script Step that is after the VS Image Selection step did not set any objects in the lisa_vse_response response property did it? 



  • 7.  Re: Error after rest step when virtual responder step is invoked.

    Posted Apr 18, 2018 02:16 PM

    Thank you Joel.

     

    Implementation worked after i changed it to beanshell as you suggested.

     

    Yes, Java script step was setting objects to lisa.vse.response response property.



  • 8.  Re: Error after rest step when virtual responder step is invoked.

    Posted Apr 19, 2018 10:47 AM

    Hi Joel,

     

    The response body setting is done using the snippet you have provided.

     

    Can you please help in Filtering the HTTP response code for the Response from POST LIVE step!!

     

    This last step in our implementation is pending, your help is very much appreciated.