I have a SOAP UI project that has the following web service response:
<env:Envelope env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Header/>
<env:Body>
<m:invokeResponse xmlns:m="some namespace">
<result xsi:type="xsd:string"><![CDATA[<?xml version="1.0" encoding="US-ASCII" standalone="yes"?><message><myVal>123</myVal></message>]]></result>
</m:invokeResponse>
</env:Body>
</env:Envelope>
I need to use an Assertion in SOAP UI to see that 123 is present which is in the XML in the CDATA section. I cannot just simply use a contains in SOAP UI Assertions as 123 might be present a couple of time witin the CDATA section. So I need to use XPath Assertion.
Now if I add an assertion XPath Match
//result/text()
It matches
<?xml version="1.0" encoding="US-ASCII" standalone="yes"?><message><myVal>123</myVal></message>
but if I change the expression to
//result[text()]/message/myVal[text()]
which should match 123 it fails
If I use a Script Assertion using groovy it works (I just used Groovy to see if it works)
import com.eviware.soapui.support.XmlHolder
respXmlHolder = new XmlHolder(messageExchange.getResponseContentAsXml())
respXmlHolder.declareNamespace("ns1","http://www.webserviceX.NET")
CDATAXml = respXmlHolder.getNodeValue("//result/text()")
CDATAXmlHolder = new XmlHolder(CDATAXml)
myval = CDATAXmlHolder.getNodeValue("//message/myVal")
assert myval == "123"
But I would like to know if there is a way to do this with an XPath Assertion inside SOAP UI. I need to handoff the project to Business that doesn't understand Groovy :)