tshanmuganathan
10 years agoNew Contributor
Asserting using GROOVY SCRIPTING
Hi Techies,
I am a SOAP UI Beginner and I am trying to validate the response XML from a simple currency converter web service :
http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
I got the response as :
################################################################################
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>63.665</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
</soap:Envelope>
################################################################################
Now I would like to validate the response and I have written the below Groovy script. However I always get value as NULL. Can someone please help me in this regard ?
==================================================
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def holder = groovyUtils.getXmlHolder( messageExchange.responseContent );
holder.namespaces["ns"] = "http://www.webserviceX.NET/";
def responseId = holder.getNodeValue["//ns.ConversionRateResult"];
log.info responseId
==================================================
The output is always NULL. I have made so many references but couldn't get the correct solution.
Please help.
I am a SOAP UI Beginner and I am trying to validate the response XML from a simple currency converter web service :
http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
I got the response as :
################################################################################
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>63.665</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
</soap:Envelope>
################################################################################
Now I would like to validate the response and I have written the below Groovy script. However I always get value as NULL. Can someone please help me in this regard ?
==================================================
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def holder = groovyUtils.getXmlHolder( messageExchange.responseContent );
holder.namespaces["ns"] = "http://www.webserviceX.NET/";
def responseId = holder.getNodeValue["//ns.ConversionRateResult"];
log.info responseId
==================================================
The output is always NULL. I have made so many references but couldn't get the correct solution.
Please help.
- check this out
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( messageExchange.responseContent )
holder.namespaces["ns"] = "http://www.webserviceX.NET/"
def conversionRate = holder.getNodeValue("//ns:ConversionRateResult")
log.info conversionRate