Ask a Question

Saving several xml responses

dmigarashi
Occasional Visitor

Saving several xml responses

Hi guys! I am using SoupUI NG to submit several xml requests, and I would like to store these responses.

I tried to use the dump file resource, but it saves only one response.

How can I store each response xml file?

 

Thanks in advance.

3 REPLIES 3
nmrao
Champion Level 3

@dmigarashi, not sure if the issue still persists.

Would you mind showing the structure of your test case / suite with some context?


Regards,
Rao.
groovyguy
Champion Level 0

You can use a groovy script assertion on required test steps like follows:

 

def projDir = context.expand( '${projectDir}' );

def label = context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel();

def response = messageExchange.responseContentAsXml.toString();

log.info(response);

def responseFile = new File(projDir + "\\" + label + ".xml");

responseFile << response;

assert responseFile.length() > 0;

 

 

 




---

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

@dmigarashi,

 

There are multiple ways to save the response. One of the way, like @groovyguy suggested, is to use Script Assertion.

 

Below is for information benefit of others.

 

I was thinking for alternative ways and got strike with ways such as TearDown Script, Events etc.,

 

If I were to do the same, go for the Events because, Script in single place and gets fired automatically.

 

In the Events also, there are multiple available to handle this case as given below:

 

 - SubmitListener.afterSubmit

 - RequestFilter.afterRequest

 - TestRunListener.afterStep

 - MonitorListener.onMessageExchange

 

I would go with last one as I feel it is more appropriate based on the descriptions here in the documentation. However, I could not get that working.

 

So, trying with 1st one i.e., SubmitListener.afterSubmit Event.

 

Create a project level custom property LOCATION and provide directory name where the responses needs to be saved say C:/Users/apps/Data (Use / as path separator even on windows)

 

Here is the script that needs to go into above mentioned event:

 

https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/readyapi/events/SubmitListener_After...

 

 

EDIT:

 

Above script is refactored / moved to below location:

 

https://github.com/nmrao/readyAPIGroovyScripts/blob/master/groovy/events/SubmitListener/afterSubmit/...

 



Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: