Testing for 0 nodes in WS XML result set


#1

I have a WS call that returns an XML as per:

<s:Envelope xmlns:s=“http://www.w3.org/2003/05/soap-envelope”>
<s:Body>
<ns0:SearchClaimLinesResponseMessage xmlns:ns0=“http://schemas.hambs.com.au/external/claim/searchclaimlines/response/2014/06” xmlns:s=“http://schemas.hambs.com.au/external/reference/speciality/2014/06” xmlns:sc=“http://schemas.hambs.com.au/external/reference/specialityclass/2014/06” xmlns:ns1=“http://schemas.hambs.com.au/external/provider/provider/2014/06” xmlns:ns2=“http://schemas.hambs.com.au/external/service/service/2014/06” xmlns:cl=“http://schemas.hambs.com.au/external/claim/claimline/2014/06” xmlns:m=“http://schemas.hambs.com.au/external/reference/message/2014/06”>
ns0:ClaimLines/
</ns0:SearchClaimLinesResponseMessage>
</s:Body>
</s:Envelope>

If the request had found data then there would be XML node(s) cl:ClaimLine after ns0:ClaimLines node …

I have tried to test node count with
WS.verifyElementsCount(targetResponse, ‘ClaimLines’, 0)
or
WS.verifyElementsCount(targetResponse, ‘ClaimLine’, 0)

but I get error

2019-11-08 14:29:41.863 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to verify element count (Root cause: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object

The current character read is ‘<’ with an int value of 60
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
<s:Envelope xmlns:s=“http://www.w3.org/2003/05/soap-envelope”><s:Body><ns0:SearchClaimLinesResponseMessage xmlns:ns0=“http://schemas.hambs.com.au/external/claim/searchclaimlines/response/2014/06” xmlns:ns1=“http://schemas.hambs.com.au/external/provider/provider/2014/06” xmlns:cl=“http://schemas.hambs.com.au/external/claim/claimline/2014/06” xmlns:ns2=“http://schemas.hambs.com.au/external/service/service/2014/06” xmlns:ns3=“http://schemas.hambs.com.au/external/reference/speciality/2014/06” xmlns:ns4=“http://schemas.hambs.com.au/external/reference/message/2014/06” xmlns:ns5=“http://schemas.hambs.com.au/external/reference/specialityclass/2014/06” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>ns0:ClaimLines/</ns0:SearchClaimLinesResponseMessage></s:Body></s:Envelope>
^
at Script1.run(Script1.groovy:1)

Am wondering if anyone has standard code for testing for zero count of XML nodes ?

cheers, thanks, Allan