Service Virtualization

 View Only
  • 1.  What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change

    Posted Mar 17, 2025 10:40 AM

    What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change.

    User Email and Wire Amount are two example incoming request attributes which increase or decrease based on request

    Below are the two different examples

    Request 1: with only 1 data attribute

    wireDetails_0_wireAmount

    wireDetails_0_userEmail

    Request 2: with 5 data attribute

    wireDetails_0_wireAmount

    wireDetails_0_userEmail

    wireDetails_1_wireAmount

    wireDetails_1_userEmail

    wireDetails_2_wireAmount

    wireDetails_2_userEmail

    wireDetails_3_wireAmount

    wireDetails_3_userEmail

    wireDetails_4_wireAmount

    wireDetails_4_userEmail



  • 2.  RE: What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change

    Broadcom Employee
    Posted Mar 18, 2025 09:30 AM

    Hi Vikram,

    You can create Two stateless transaction for the above scenarios if you looking for only those.

    If you are looking for Dynamic behavior with one transaction then, we need more details. Can you open a support case and we can have a call an look into the functionality.

    Regards,

    Prema




  • 3.  RE: What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change

    Posted Mar 18, 2025 09:39 AM

    Thanks for the response Prema.

    There are going to be multiple transactions where incoming attributes count changes based on the test case.

    I will open a service request for further discussion 




  • 4.  RE: What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change

    Posted Mar 18, 2025 10:00 AM

    Hi Vikram.. 

    We would need more details on this, to provide a comprehensive solution.. for ex. response details (static or dynamic), no. of operations in the service, what would be the min match criteria etc..

    But, with the limited details available in your request, we can think of few options 

    Option-1 : Considering the response as static

    • Capture a transaction and apply operation match. Update the static response in the transaction

    Option-2: Assuming Minimal match criteria (For ex. Irrespective of the signature, you just need to match only 1 wire amount and/or user email)

    • You can create a signature with you Request-2 details and apply Selective match for 2 arguments (wireDetails_0_wireAmount, wireDetails_0_userEmail) or just any one of the argument depending on the requirements (may be userEmail)

    Option-3: Using the RDM

    • Using the RDM, create a template Signature with maximum possible wireAmount & userEmail arguments (let's say, around 15)
    • Use matching criteria according to the Test scenario you want to test

    Option-4: All dynamic (request & response)

    • The only way to handle this scenario is to do some custom scripting
    • It can be using Match script or SDPH or sometimes with a Simple Assertion too.

    If you can provide more insights into your requirements with some example test scenarios, I can provide better guidance

    Thank you,
    Senthil Manohar, Canada Life Assurance Co.




  • 5.  RE: What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change

    Posted Mar 18, 2025 11:04 AM

    Thanks for detailed response.

    Request may come with 5 wireDetails_0_wireAmount attributes, sometimes more than that. The requirement is to compare all the incoming wireDetails_0_wireAmount attributes with a value. If any of them are greater than the comparison, it should return a specific response; if not, the default response should be returned.

    could you please elaborate on RDM?

    Thank for quick response.




  • 6.  RE: What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change

    Posted Mar 18, 2025 04:33 PM

    Please read more about RDM (Request Data Manager) here Request Data Manager Data Protocol

    Using the RDM, create 15 arguments of "wireDetails_0_wireAmount" and update the signature accordingly. Once done, you can set the comparison parameter to compare the incoming value against the desired value. Update the required response according to the matching criteria.

    The above solution is not 100% dynamic and if there are more than 15 "wireDetails_0_wireAmount" arguments, the solution will fail.

    To achieve 100% dynamic solution, we need to do some scripting. If you find a better solution, please update in the thread for reference.




  • 7.  RE: What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change

    Broadcom Employee
    Posted Mar 18, 2025 09:49 PM

    Hi Vikram,

         Recently we received a similar requirement from a customer and I have suggested the solution with the match script in VSI file. 

    Try below match script to retrieve the arguments dynamically with below script. 

    /* MATCH SCRIPT TO RETREIVE WIREAMOUTN VALUE DYNAMICALLY -- START*/

    String amount= incomingRequest.getArguments().get("__wireDetails_0_wireAmount");
    int count;
    for (count=1; amount!=null ; count++)
    {
    amount= incomingRequest.getArguments().get("__wireDetails_"+count+"_wireAmount");
    testExec.setStateValue("count",count);
    }

    /* MATCH SCRIPT TO RETREIVE WIREAMOUTN VALUE DYNAMICALLY -- END*/

          If you want to perform any actions after retrieving argument value, you can add logic inside the for loop.

    Thanks,

    Srikanth




  • 8.  RE: What is the option to create virtual services for REST API based calls where the incoming request attributes expected to change

    Broadcom Employee
    Posted Mar 19, 2025 09:17 AM

    Vikram opened a support case Yesterday and I had a call and looked at the functionality he is looking. 

    As the arguments are dynamic and he want to select a specific response based on the WireAmount, I recommended him to get the count of WireDetails using JSON Path Filter and then use the count in Match Script to loop through all arguments and return true or false to match the transaction.

    He is going to try the recommendation and update support.

    Appreciate your inputs Senthil and Srikanth.

    Prema