WS getting value of the element of webservice response

Hi everyone,

I’ve faced with the problem of getting the value of the element from the web-service response.

Example of response:

<s:Envelope xmlns:s=“”>

_ <s:Body>_

_ _

_ _

_ <a:Code>DCFW_fe6f4fad-9fad-4bd5-a0e3-94325bcb4ba0_

** </a:Code>**

_ <a:PdfBytes>JVBERi0…_

_ </a:PdfBytes>_

_ _

_ _

_ </s:Body>_


I need to verify that the value of the Code like ‘**DCFW.*’
**_The problem is that method **Verify Element Text **doesn’t support RegEx. If I use **Verify Match **I need the specific element from the response.
How can I solve this issue?

it’s always a good idea to parse response to get to the value:

def response = '''<s:Envelope xmlns:s="">  <s:Body>    <GenerateDocumentResponse xmlns="">      <GenerateDocumentResult xmlns:a="" xmlns:i="">        <a:Code>DCFW_fe6f4fad-9fad-4bd5-a0e3-94325bcb4ba0        </a:Code>        <a:PdfBytes>JVBERi0...        </a:PdfBytes>      </GenerateDocumentResult>    </GenerateDocumentResponse>  </s:Body></s:Envelope>'''String code = new XmlSlurper().parseText(response).'**'.find {'Code'}assert code.contains('DCFW')

1 Like

Thanks a lot!
That’s what i need