aName
aName

Reputation: 3063

How to pass parameter to SOAP request in SOAPUI

I'm newbie to soap and soapui, I'm trying to create a test case in which I will send the same request(XML attachment) many times(about 500), the problem is that each time I need to increment/change a value in the request (the id).
Therefore, I wonder if the is a way to pass this parameter to the attached xml file ? or if there is another ways to do the test case.
Thank you in advance
UPDATE
here is the content of the xml file :

<mod:sendMSG xmlns:mod="http://test.soap/service/model">
  <id>${#Project#parameter1}</id>
  <date>2016-04-03T04:03:00</date>
  <infos>
        <firstName>AT </firstName>
        <lastName>AT </lastName>
        ......
  </infos>
</mod:sendMSG>

which is included in the soap request, ass shown in the following image :
enter image description here

Upvotes: 0

Views: 4284

Answers (1)

einaralex
einaralex

Reputation: 101

Test steps:

  1. Groovy Script

  2. SOAP Request (disabled)

I disabled the SOAP Request because it runs once more after the script has already looped the request x times.

Groovy script:

int loops = 500;

for ( iter in 1..loops ) {

    //Overwrite the 'parameter1' property at project level
    testRunner.testCase.testSuite.project.setPropertyValue("parameter1", iter.toString())

    //log.info("iter: " + testRunner.testCase.testSuite.project.getPropertyValue("parameter1"));

    // Run the teststep named 'SOAP Request'
    def testStep = testRunner.testCase.testSteps['SOAP Request'];
    testStep.run( testRunner, context )
}

Now you should be able to run your TestCase. I recommend saving your project before, I had some problems with SoapUI crashing on me when running.

Upvotes: 1

Related Questions