ArturoMartinez
12 years agoOccasional Contributor
Extract info from XML returns null
Hi @ll!
I'm new to SoapUI and to Groovy Scripts.
So far, I've read some tutorials and I'm trying to launch my own TestSuite.
This suite just have a TestCase with 2 TestSepts, 'Ping' and 'Script'.
After Ping (wich runs ok) I want my script to get response and parse through XML nodes and get 'return' node.
Ok, so here's the XML response by 'Ping':
And here's the 'Script's code:
But it always returns 'null'.
Thanks for your responses in advance.
I'm new to SoapUI and to Groovy Scripts.
So far, I've read some tutorials and I'm trying to launch my own TestSuite.
This suite just have a TestCase with 2 TestSepts, 'Ping' and 'Script'.
After Ping (wich runs ok) I want my script to get response and parse through XML nodes and get 'return' node.
Ok, so here's the XML response by 'Ping':
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dlwmin:PingResponse xmlns:dlwmin="http://dvtransaction.com/">
<return>System is loaded</return>
</dlwmin:PingResponse>
</soapenv:Body>
</soapenv:Envelope>
And here's the 'Script's code:
def tsuite = testRunner.testCase.testSuite;
def tcase = tsuite.testCases["FirstTestCase"];
def tstep = tcase.getTestStepByName("PingTest");
def gutils = new com.eviware.soapui.support.GroovyUtils( context );
if (gutils != null)
{
def holder = gutils.getXmlHolder(tstep.getPropertyValue("response"));
if ((holder.hasProperty('xml')) && (holder != null))
log.info(holder.getNodeValue('return'))
else
log.info('error: holder is null or has no property xml');
}
else
log.info('error: gutils is null');
But it always returns 'null'.
Thanks for your responses in advance.