Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Virtual Asset to respond with different responses for the same req param (stateful)

Saranya
Saranya Posts: 3
edited June 2021 in Virtualize

Hi,

Can someone throw light on the following situation please?

I have a Virtual Asset which is invoked by ColumnID. When the ColumnID "XYZ" invokes the VirtualAsset for the first time, the VA should respond with a particular xml and for the second time if the Virtual Asset is invoked with the same ColumnID "XYZ", then the response should be different and third time if the same ColumnID is invoked then a different response should be sent.
In bottomline we need different responses for the same ColumnID if it is invoked at different times.
Is there a way that this scenario could be handled?

Thanks in advance.

Answers

  • Ireneusz Szmigiel
    Ireneusz Szmigiel Posts: 228 ✭✭✭
    edited September 2017

    Hi Saranya,

    As I see it, you need to get every time a different response, however..
    A) Do you need the same format of response with different values?
    B) Do you need a random behavior?

    If you are looking for A then check Parasoft Marketplace and find Custom String Tool and Random Number Generator.
    You can use them to generate values in response which will be correlated by ColumnID

    If you are looking for B then maybe check Responder Randomizer from Marketplace.
    You may need to download Custom Extension Utility Package as some of the tools from Marketplace need it.

  • Saranya
    Saranya Posts: 3

    Hi Ireneusz,

    Thanks for your update.

    In my scenario, I would need a same format but with added values each time. For example, for the first time it gives 10 lines of xml response and for the second time it will be 12 lines with added values to the previous response and so on.

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    Hi Saranya, here is one way to do it:
    1. Create a pva with responders that do Responder Correlation based on a HTTP header
    2. Create a file that contains the initial value
    3. Create another pva with a responder that would act as a gateway; attach an Extension Tool to the responder's Incoming Transport Header that reads the value from the file, sets it to a variable, and writes the incremented value to the file; attach a Message Forward tool that forwards the request to the pva set up in step 1, using the variable as the HTTP header
    4. The client application would invoke the gateway pva

    For more information on Extension Tool and Message Forward, you can consult the Help documentation.

  • meghana1
    meghana1 Posts: 29

    "in our case, the request would be triggered only once and not again and again. When a request is triggered it would send 3 responses, we are unable to configure the same"

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    Hi meghana1, your case is different from the issue of this thread. You have started a thread on your issue, right?