massimo65
6 years agoNew Contributor
How to extract a value from a SOAP response
I am new with SoapUI tool. I need to extract the values of "resultOperation" and "errorCode" from the following SOAP response:
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: text/xml...
- 6 years ago
You may use below Script Assertion:
assert context.response, 'Response is empty or null' def xml = new XmlSlurper().parseText(context.response) def getElementValue = { element -> xml.'**'.find{element == it.name()}?.text() } log.info 'resultOperation value is ' + getElementValue('resultOperation') log.info 'errorCode value is ' + getElementValue('errorCode')
Here is the script which you can play and test it online with fixed response.