singhtester
14 years agoContributor
java.lang.NullpointerException for getNode value
Hi,
I want to save the value of node in some file, or save as Global in suite to be used in next tests.I am using Soapui and getting java.lang.NullpointerException when i run the groovy script.
Can some one suggest, If I am missing anything.
Groovy script for saving the node value:
==========================================
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def responseHolder = groovyUtils.getXmlHolder("TS_testLogOn_Valid#Response");
responseHolder.declareNamespace( 'se', 'http://demoexample.com')
MA_UUID=responseHolder.getNodeValue("//se:testLogOnResponse[1]/testLogOnResult[1]/val[1]");
def myOutFile = "C:/TEMP/webservice/Response/value.xml"
def f = new File(myOutFile)
f.write(MA_UUID, "UTF-8")
My XML response:
================
<testLogOnResponse xmlns="http://demoexample.com/">
<testLogOnResult>
<time>1329928021357</time>
<status>true</status>
<TSviewer>537804597898115108</TSviewer>
<othercookies>
<CookiesArrayEntry>
<name>ibssid</name>
<val>13b7e5e42fff4080a4899ddb940d8dbd7b7d3c962037a516d87c83e62cd3e8ca</val>
</CookiesArrayEntry>
</othercookies>
<dosignon>false</dosignon>
</testLogOnResult>
</testLogOnResponse>
Thanks.
I want to save the value of node in some file, or save as Global in suite to be used in next tests.I am using Soapui and getting java.lang.NullpointerException when i run the groovy script.
Can some one suggest, If I am missing anything.
Groovy script for saving the node value:
==========================================
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def responseHolder = groovyUtils.getXmlHolder("TS_testLogOn_Valid#Response");
responseHolder.declareNamespace( 'se', 'http://demoexample.com')
MA_UUID=responseHolder.getNodeValue("//se:testLogOnResponse[1]/testLogOnResult[1]/val[1]");
def myOutFile = "C:/TEMP/webservice/Response/value.xml"
def f = new File(myOutFile)
f.write(MA_UUID, "UTF-8")
My XML response:
================
<testLogOnResponse xmlns="http://demoexample.com/">
<testLogOnResult>
<time>1329928021357</time>
<status>true</status>
<TSviewer>537804597898115108</TSviewer>
<othercookies>
<CookiesArrayEntry>
<name>ibssid</name>
<val>13b7e5e42fff4080a4899ddb940d8dbd7b7d3c962037a516d87c83e62cd3e8ca</val>
</CookiesArrayEntry>
</othercookies>
<dosignon>false</dosignon>
</testLogOnResult>
</testLogOnResponse>
Thanks.