Service Virtualization

 View Only
  • 1.  How to take a VSI matched response and turn it into a new request?

    Posted Aug 03, 2016 04:51 PM

    Hi, I've been requested to try a proof of concept for DevTest Service Virtualization. Normally in DevTest, I make a VSI/VSM out of a request/response pair (for WebService), where you have a DevTest virtualizing one system. We send in one request into System A (DevTest) and it spits the response of A right back.

     

    I've been asked to see if its possible to do something where we have a request going into System A, instead of simply returning a response, we can use that response as a request input into a System B, and then have the response of B returned as the final response. So instead of User --> A --> User, we have User --> A --> B --> User.

     

    I've been trying to design a method with two VS Image Selection Response steps in series (with different VSI each, virtualizing two different systems A & B) and trying to find a way to use the VSI matched response of A as the request of B. Can anybody help me with this?

     

    I can see the Virtual HTTPs Responder step uses a property called "lisa.vse.response". I also don't understand how to modify this property or how it is used internally during the VS Image Selection Response step. I am also having trouble finding information on this.

     

    Any help or information would be appreciated, thanks!



  • 2.  Re: How to take a VSI matched response and turn it into a new request?

    Broadcom Employee
    Posted Aug 03, 2016 05:00 PM

    To implement User --> A --> B -->  User, my suggestion would be create a standalone Virtual Service B using appropriate RR pairs.

     

    Create Virtual service A as usual using its RR pairs. In the model of VS A, after the VS Image response selection step, manually add a step (say CallVS_B) to invoke the second VS (VS B) using the response from the previous step as the request for this manual call.

     

    The response received from this manual call (available in lisa.CallVS_B.rsp) can then be used to update "lisa.vse.response" to send back appropriate response to the User.



  • 3.  Re: How to take a VSI matched response and turn it into a new request?

    Posted Aug 04, 2016 10:54 AM

    Hi Prem, thanks for your reply, I'm still a bit of a novice at DevTest so I'll probably need a bit more explanation.

     

    I understand the logic of how this works and I already have two seperate VS Images A & B created. However, I do not know how to invoke VS B using response of A. I have tried making a Request using testExec.setStateValue using lisa.vse.response and that doesn't work. What step is available that can accept a response and make that into a new request?

     

    Where can I find information on how to work with lisa.vse.response or in your example, the method surrounding (lisa.CallVS_B.rsp)?



  • 4.  Re: How to take a VSI matched response and turn it into a new request?
    Best Answer

    Posted Aug 17, 2016 01:58 PM

    Prem's suggestion means adding a new step into Service A.  Your Service B will need a VSM capable of handling the incoming response from Service A as input not the original incoming request into Service A.  If the latter, there would be no need for Service B.

     

    When you get the response from Service A's VSI selection step,

    - Save the response value off into a property.  For example, using a Scripted Assertion you could:

    // parse in state is used in case you have magic string data that needs to be substituted

    // get body as string gets the response body from the first lisa_vse_response which is a List object

    // set state value places the response in a property name of your choice

    testExec.setStateValue("theResponse", testExec.parseInState( lisa_vse_response.get(0).getBodyAsString() ) ); 

    return true;

    And, change the Assertion to only fail when the return is false.

     

    Add a new WebService Execution step after the VSI Selection step.  CLICK VS Image Selection, RIGHT CLICK, Add WS Exec... Step.  In this step,

    - make the request body equal to your {{theResponse}} and

    - call Service B's endpoint. 

        You might also have to develop a base path or you could use "/" for the call so Service B accepts all incoming requests. 

        In Service B, the response from Service A is the input or incoming request, so take care of the mapping accordingly using your favorite DPH(s).

     

    - Inside the WebService Execution step in Service A, Filter the response from the call to Service B into a filter property (theResponseFromB) and

      add another Scripted Assertion to this step to set the response into Service A's response.  For example, 

    lisa_vse_response.get(0).setBody( testExec.getStateValue("theResponseFromB") ); 

    return true;

    And change the Assertion to only fail when the return is false.

     

    Then, let Service A respond using its Responder step.  lisa_vse_response body will contain Service B's response.

     

    Pardon typos in the above example. 

     

    Also, you might want to set Service B's VSI response Think Time to 0 and let the Think Time provided by Service A's VSI selection prevail.  Otherwise, you will incur two think times.  One in Service A waiting for the response from Service B and another when Service A replies to the SUT with the final response.  You might not want the added Think Time.



  • 5.  Re: How to take a VSI matched response and turn it into a new request?

    Posted Aug 29, 2016 03:52 PM

    Hi Joel,

     

    Thank you for your reply, the instructions are quite helpful in my progress. However, I am still running into quite a few issues and problems. I am able to successfully retrieve a response, but I am unable to get the WebService Execution working despite going through the tutorials online. I always get a Connection refused error. How do I setup another endpoint for Service B? I tried putting another Listener step with a port and base path after the Web Execution Step and it doesn't work.

     

    Also, through a bunch of experiments, I found that the request body following the Listener (lisa.vse.request) has a lot of additional information compared to the actual request payload you send in; including a lot of parsed information about the request as well as a block of metadata information. It is not as simple as saving a response into a property and firing it through a second VSI Image Selection (for Service B).

     

    Is there a way I can contact you directly? I am obviously inexperienced with DevTest and I'm struggling a lot with this. 

     

    Thanks a lot for the help again, I really appreciate it. 



  • 6.  RE: How to take a VSI matched response and turn it into a new request?

    Posted Sep 17, 2020 01:29 AM
    I know this is an old post, but I would Keep it simple. take the input and send the output with minimal processing and internal calls.

    Have a single simple virtual service. It accepts request for A. But the VSI will have response for B instead of A. You just need to match request of A to the response of B.

    I hope it makes sense!