Saving several xml responses
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would you mind showing the structure of your test case / suite with some context?
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
EDIT:
Above script is refactored / moved to below location:
Regards,
Rao.
