user3212324 user3212324 - 2 months ago 34
Groovy Question

Groovy Script - Automatic Request and saving response from SOAP UI

I am new to Groovy scripting.

Requirement To read the request values from a text file and pass it to the soap request xml and save the output.

Issue facing: I am not able to read the data from step 1 to step 2. However I am setting the values in context variable as well. Kindly help me to fix the issue so that I can able to automate the entire process.

Note: We have only access to SOAPUI not SOAPUI Pro

Step 1:

File file1 = new File("C:\\Users\\Groovy Test\\requests\\orders.txt")
List textLine = file1.readLines() textLine
context.put('textLine', textLine) textLine

Step 2:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="">
<OrderId>${context.get('textLine' )}</OrderId>

Step 3:

def fileList = context.get('textLine')
def fileName = fileList.pop()
def newname = fileName[0..-5]
def response = context.expand( '${Step2#Response}' )
def f = new File("C:\\Users\\Groovy Test\\responses\\${fileName}_Response.xml")
f.write(response, "UTF-8")
if(fileList.size() >0)


I think that the problem is the notation in the Xml of the step 2:



Instead of:


Note the = character.