Forum Discussion

massimo65's avatar
massimo65
New Contributor
6 years ago
Solved

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...
  • nmrao's avatar
    6 years ago

    massimo65 

    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.