Forum Discussion

Alejandro21's avatar
Alejandro21
Occasional Contributor
11 years ago

Generating the request values at runtime..

Hi all,

I have a test case with 3 test steps that basically do these:
Step 1: Groovy script that uses XmlHolder to generate the request step 2 will send using a specified business logic
Step 2: Soap Request
Step 3: Groovy script that analyzes and stores the values received by step 2 request.

I've notice that step 1 takes more time to execute than the one I would expect. I have two questions that might help me improve the step performance

1) Because every time the case runs the request is based on the request generated the last time the case was executed,step 1 has to add/delete nodes according to the established business logic. I guess this nodes content analysis is what makes the step slow. Is there a way I can erase all the node values at the start of the script? I guess it would be faster to start generating the node values while working with a "clean" xml every time.
2) In the end, I'll create a load test based on this test case and I want that every time the case runs, the majority of the time is being spent in step 2. I was wondering if there is a way that, instead of using XmlHolder+logic, I could store all the different xmls the load test will send in a Data Source (DB) and have a simpler groovy script that only reads the xml from the data source and replaces the request xml. Is this even possible? If positive, does anybody have a starting point to share?

Any other suggestions of how I can do this are more than welcomed!

Regards,

Alejandro
  • Hi,

    You would have to use some XmlHolder logic still to get the Nodes and set their values to an empty string for instance.
    Or you could adapt this script to do what you need: http://www.soapui.org/Scripting-Properties/tips-a-tricks.html#5-2-remove-empty-xml-elements-from-request.
    It's certainly possible to have a DataSource that loads values that are the various XML requests that you need to send also. It could be an Excel sheet with with a different request on each row like the attached file. Then you would retrieve the value at each iteration of your DataSource and set it as the current request in your Groovy TestStep. You can see then how that would fit with the business logic you mentioned to populate the request.

    Regards,

    Giscard
    SmartBear Support
  • Alejandro21's avatar
    Alejandro21
    Occasional Contributor
    Hi Giscard,

    Thanks for your reply. Yes, a datasource like the xls file you sent is why I'm looking for. DO you recommend using an excel file instead of a DB connection?

    However, I'm not sure how to set each iteration of my DataSource as my current request xml, could you give some simple code example of how to achieve it?

    Actually, what I would like to have in the end is a DataSource that includes not only the requests nodes but also their corresponding values. Something like preparing all the load test data in advanced based on my business logic so that when the load test runs, it only iterates through the DataSource and sends the requests.

    Thanks!

    Alejandro
  • Hi,

    You may also use a DataSource of type JDBC and you would iterate through each row, to pull a different XML request coming from your database.
    Then in a Groovy script for instance you could retrieve the current property (current row value) from the DataSource using the right-click->Get Data... functionality as shown in the screenshots.
    Next you would change the request using custom coding, which we do not support. You can use the following resources as pointers:
    http://www.soapui.org/Scripting-Properties/tips-a-tricks.html#5-change-a-request-xml-from-groovy
    http://www.soapui.org/apidocs/com/eviware/soapui/support/XmlHolder.html

    Regards,

    Giscard
    SmartBear Support