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=“http://schemas.xmlsoap.org/soap/envelope/”>

_ <s:Body>_

_ _

_ _

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

** </a:Code>**

_ <a:PdfBytes>JVBERi0…_

_ </a:PdfBytes>_

_ _

_ _

_ </s:Body>_

</s:Envelope>

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?

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

def response = '''<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">  <s:Body>    <GenerateDocumentResponse xmlns="http://schemas.it.mts.ru/DocFlow/DocFlow/ServiceContracts">      <GenerateDocumentResult xmlns:a="http://schemas.it.mts.ru/DocFlow/DocFlow/Entities" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">        <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 {it.name()=='Code'}assert code.contains('DCFW')

1 Like

Thanks a lot!
That’s what i need

welcome