CRW123456
15 years agoNew Contributor
Script assertion for CDATA payload
soapUI v3.6.1
I am attempting to implement assertions on CDATA payload as outlined in http://soapui.org/Functional-Testing/working-with-cdata.html.
Here is snippet of my message:
Here is my script:
Note that I've added logging statements to help debug. Here is the output:
So, it looks to me as if payload is getting created and contains nodes but payloadHolder is not getting initialized as expected -- it's size is zero and the keySet null. Hence, I can't get to any of the elements within the CDATA section of the message. What am I doing wrong? Is the behavior I'm expecting available in this version of soapUI? Any help would be appreciated.
Thanks,
Curtis ...
I am attempting to implement assertions on CDATA payload as outlined in http://soapui.org/Functional-Testing/working-with-cdata.html.
Here is snippet of my message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ia:GenericProxyServiceResponse xmlns:ia="http://www.xxx.com/xxx">
<responseHeader>
...
</responseHeader>
<responseData>
<![CDATA[
<NS1:retrievePaymentScheduleResponse xmlns:NS1="http://eigns.xxx.com/PaymentScheduleFacade">
<NS1:retrievePaymentScheduleResponseBody>
<NS1:paymentScheduleResponse>
<NS1:paymentPlanCode>D3</NS1:paymentPlanCode>
...
]]>
</responseData>
...
Here is my script:
import com.eviware.soapui.support.XmlHolder
def cdataHolder = new XmlHolder(messageExchange.responseContentAsXml)
def payload = cdataHolder.getDomNode("//responseData")
assert payload != null
log.info(">>> payload.toString() = " + payload.toString())
log.info(">>> payload.hasChildNodes()=" + payload.hasChildNodes())
def payloadHolder = new XmlHolder(payload)
assert payloadHolder != null
payloadHolder.declareNamespace("ns", "http://eigns.xxx.com/PaymentScheduleFacade")
log.info(">>> payloadHolder.isEmpty()=" + payloadHolder.isEmpty())
log.info(">>> payloadHolder.size() = " + payloadHolder.size())
def keys = payloadHolder.keySet()
log.info(">>> keys=" + keys)
log.info(payloadHolder.getNodeValue("/ns:retrievePaymentScheduleResponse/ns:retrievePaymentScheduleResponseBody/ns:PaymentScheduleResponse[1]/ns:paymentPlanCode"))
log.info(payloadHolder["//ns:PaymentScheduleResponse[1]/ns:paymentPlanCode"].toString())
Note that I've added logging statements to help debug. Here is the output:
Wed Sep 28 10:30:25 EDT 2011:INFO:>>> payload.toString() = <?xml version="1.0" encoding="UTF-8"?>
<responseData xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ia="http://www.xxx.com/xxx">
<NS1:retrievePaymentScheduleResponse xmlns:NS1="http://eigns.xxx.com/PaymentScheduleFacade">
<NS1:retrievePaymentScheduleResponseBody>
<NS1:paymentScheduleResponse>
<NS1:paymentPlanCode>D3</NS1:paymentPlanCode>
...
</responseData>
Wed Sep 28 10:30:25 EDT 2011:INFO:>>> payload.hasChildNodes()=true
Wed Sep 28 10:30:25 EDT 2011:INFO:>>> payloadHolder.isEmpty()=false
Wed Sep 28 10:30:25 EDT 2011:INFO:>>> payloadHolder.size() = 0
Wed Sep 28 10:30:25 EDT 2011:INFO:>>> keys=null
Wed Sep 28 10:30:25 EDT 2011:INFO:null
Wed Sep 28 10:30:25 EDT 2011:INFO:[]
So, it looks to me as if payload is getting created and contains nodes but payloadHolder is not getting initialized as expected -- it's size is zero and the keySet null. Hence, I can't get to any of the elements within the CDATA section of the message. What am I doing wrong? Is the behavior I'm expecting available in this version of soapUI? Any help would be appreciated.
Thanks,
Curtis ...