Search code examples
xmlgroovysoapuidata-driven-tests

how send multiple request in soap ui using groovy


I have to run xml request in soap ui with variable.as I understand it is possible with using groovy script. My variable ($variable) should be like:

for (i = 0; i < 5; i++) {
createResult(34620000+i)
}

Request looks like:

SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:xmethods-delayed-quotes">
<SOAP-ENV:Body>
 <wq:test>
  <Date xsi:type="xsd:string">2015-01-26</Date>
  <Data ..."$variable"...</Data>
 </wq:test>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Could someone help me to send such request. Or maybe there is another way to send multiple requests?


Solution

  • Here you go: Define a test case with 3 steps

    1. Groovy Script step ==> Name it testCaseControl, you can have below code
    //run the SOAPRequestStep 5 times, increase as needed
    for(int i=0;i<5;i++) {
       testRunner.testCase.setPropertyValue('VARIABLE',i.toString()) //set whatever String value required in place of i.toString()
       testRunner.runTestStepByName('SOAPRequestStep')
    }
    testRunner.runTestStepByName('ExitScript')
    
    1. TestRequest step ==> Name it SOAPRequestStep, have value as ${#TestCase#VARIABLE} in place of $variable as you mentioned
    2. Groovy Script step ==> Name this as ExistScript. This is just used to exit, you may have below code here just to finish the test case.
    log.info "Running Exit Script"
    

    Now run the test case.