Ask a Question

Saving request and response

Occasional Contributor

Saving request and response


SOAP UI Screenshot.PNGI want to save request and response of all the tests(Failed/Passed) from my Automation test suite.

The folder location should be like ProjectName-->TestSuiteName(Multiple folders for multiple test suite)-->TestCaseName(Multiple folder for multiple test cases)- a single .xml file containg request and response of test steps (Multiple files for multiple test steps).

Champion Level 0

Are you familiar with groovy scripting? That might be the easiest way to accomplish this.


Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!

Hi @pankajmalinda


There's a groovy event handler that does this quite nicely - the following script will record the request and response for each test step as well as the pass/fail result for every test step, in every test case, in every test suite in a project.


The event handler is 'TestRunListener.AfterStep'


The script is as below:  

def pName = //get project name
def pDate = new Date().format( 'yyyyMMdd' )//get current date
def sDate = pDate.toString()//convert date to string
def pTestSuite = TestSuite name
def pTestCase = TestCase name
def filePath = 'C:/SoapUI Projects/TS0.1/TestEvidence/'+pName+'_'+sDate+'/'+pTestSuite+'/'+pTestCase+'/'//compose the folder path

File file = new File(filePath)
if (!file.exists()) file.mkdirs()//create the destination folder

fos = new FileOutputStream(filePath+ testStepResult.testStep.label + '.txt', true)
pw = new PrintWriter( fos )
testStepResult.writeTo( pw )


I think this is brilliant - can't claim it was my code - I found it somewhere on - but it records everything!


I use it as a way to capture my test evidence


Hope this helps,





if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Showing results for 
Search instead for 
Did you mean: