0

as discussed HERE in soapUI free version i'm trying to call this WS:

    <soap:Body>
<RequestParameters>
    <Parameter name="key" value="SomeorderId"/>
</RequestParameters>
    </soap:Body>

and i want to take the values of "key" from a local data.txt file on my desktop. the content of this file:

9999999991
9999999992
9999999993

to do so, i've created a test suite with below three test steps:

1.first step: a groovy script:

def data = new File('C:/Users/Polarick/Desktop/data.txt') 
data.eachLine { orderId ->
   context.orderId = orderId
   //Get the step2, index of the step is 1
   def step = context.testCase.getTestStepAt(1)
   //Run the step2
   step.run(testRunner, context)
}
//all the orders got executed,jump to step2, index is 2
testRunner.gotoStep(2)

2.second step: modifying request:

<Parameter name="MSISDN" value="${orderId}"/>

and asserting this script to it:

//Check if there is response
assert context.request, "Request is empty or null"

//Save the contents to a file
def saveToFile(file, content) {
    if (!file.parentFile.exists()) {
         file.parentFile.mkdirs()
         log.info "Directory did not exist, created"
    }
    file.write(content) 
    assert file.exists(), "${file.name} not created"
}

def response = context.expand( '${Step2#Response}' )
def f = new File("C:/Users/Polarick/Desktop/${context.orderId}_Response.xml")
f.write(response, "UTF-8")
saveToFile(f, context.response)

3.Third step: a groovy script:

log.info "Test completed."

It all works fine and calls the WS for all lines existing in data.txt file sequentially, but i'm expecting to find a response .xml file per execution, for example:

C:/Users/Polarick/Desktop/9999999991_Response.xml
C:/Users/Polarick/Desktop/9999999992_Response.xml
C:/Users/Polarick/Desktop/9999999993_Response.xml

but there is no response file generated, can you help?

polarick
  • 23
  • 3
  • Do the soapUI script or error logs show any errors or exceptions? – craigcaulfield Dec 19 '19 at 00:31
  • i'm getting this error on soap step(2nd step): Request is empty or null. Expression: context.request – polarick Dec 22 '19 at 06:27
  • Store the values as properties, and parameterise it in the request XML like explained here: https://stackoverflow.com/questions/58525954/how-can-i-make-requests-in-a-loop-in-soapui-with-different-content/58535311#58535311 – ou_ryperd Dec 26 '19 at 16:20

0 Answers0