Ideas/Suggestions - Dynamic Parameters

vkumarvkumar Posts: 29

I have a requirement where responses should be very dynamic based on the request.
Based on the incoming request elements , elements/array of elements in response should vary. I m trying to minimize the no of res ponders and manual data setup.
Currently i m achieving this scenario by using xpath(function count/exists), Data correlation and a data source(Exclude with empty string) options.

Is there any way , based on incoming element exists or not , i should be set/unset block of elements (without using the data source).

Pl note, I' m aware of the multiple responses generator from Market place.

Suggestions / ideas welcome.

Comments

  • OmarROmarR Posts: 186 admin

    Greetings vkumar!

    If you wish to minimize the number or responders and manual data setup, I would recommend recording your desired traffic using a Message Proxy. Once you have generated a traffic file from your proxy, Virtualize can create parameterized messages (Minimizing the creation of responders) with auto-correlation and store your traffic in a data repository (minimizing manual data setup). This would be the most efficient way to setup both your message responders and data sources.

    ...........but, I suspect you are aware of this already. :#

  • benken_parasoftbenken_parasoft Posts: 395 ✭✭✭

    Marketplace also has a "Responder Randomizer tool" if that helps.

  • vkumarvkumar Posts: 29

    Thank you Omar and Benken for your inputs. I m looking for a solution which can store the incoming element status as exists or not from the request XML and would transform the response XML accordingly. Currently we have option with data source(Exclude with empty string). It would be great, If that is going to work with Generated Data Source as well :-)

  • vkumarvkumar Posts: 29

    Currently i m using an extension tool to get the necessary inputs and remove the response elements as string. Then im serializing it to beautify.
    Earlier,
    I was trying in groovy to use the XML slurper and tried to replace a node(delete a node) but its not working. Anybody has experienced similar issue before ?

  • OmarROmarR Posts: 186 admin

    Hello Vinoth,

    If you wish to remove or replace a known element from an XML payload, you can use the replaceAll method. For example, if a user wishes to remove "child2" element from the following XML:

    The Groovy script below will do the trick.

    import com.parasoft.api.*;
    
    public String ReplaceNode(Object data){
        data = data.toString().replaceAll("<child2>Jerry</child2>", "");
        return data.toString();
    } 
    //Groovy
    

    Give this a shot. If you run into any hurdles, kindly provide a sample .pva/.tst so that we can look into this further.

  • vkumarvkumar Posts: 29

    Hi Ramiro , Thank you
    Currently i have done only the string implementation but im unable to beautify the output by serializing it. As i have respond dynamically based on input parameters the lines of code in parsing is high as its not the single element i have to delete as i have to delete the array.

    Another approach i tried but not working is using XML Slurper and replacenode option.The replace option is not working as intended. Has anyone experienced this before

  • OmarROmarR Posts: 186 admin
    edited March 2017

    Hello Vinoth,

    My name is Omar :)

    Also, I don't see any sample file attached to your post. Is there a sample file that you can provide that demonstrates the replace method "not working as intended"

Sign In or Register to comment.