Venkat
18 years agoNew Contributor
java.lang.NullPointerException: Cannot get property: value on null object
Hi,
I am running my very first groovy script inside SoapUI. I get the error mentioned in the subject of this message. Here is the code I used ( which I copied from the SoapUI User guide ):
----------------------------------------------------------------------------------------
def request = testRunner.testCase.getTestStepByName( "Groovy Script" );
def property = request.getProperty( "request" );
// parse out textnodes to modify
def node = new groovy.util.XmlParser(false,false).parseText(property.value);
def textNodes = node["soapenv:Body"]["sam:getContactInfo"]["String_1"][0].children()
// modify
textNodes.clear();
textNodes.add( "test" + System.currentTimeMillis() );
// write back to string
def writer = new java.io.StringWriter();
def printer = new groovy.util.XmlNodePrinter( new PrintWriter( writer ));
printer.print( node );
// set property
property.setValue( writer.toString() )
-------------------------------------------------------------------------------------
What am I doing wrong? Should I have to set something before I run my script? I get this error even if I run the load test from the command line.
Also, is there a place I can go to for seeing working examples of groovy scripts inside SoapUI. I want to call different methods inside a Webservice and the inputs to successive webservice calls will be based on the responses to previous webservice calls.
Any help you can provide will be greatly appreciated.
Thanks,
Venkat
I am running my very first groovy script inside SoapUI. I get the error mentioned in the subject of this message. Here is the code I used ( which I copied from the SoapUI User guide ):
----------------------------------------------------------------------------------------
def request = testRunner.testCase.getTestStepByName( "Groovy Script" );
def property = request.getProperty( "request" );
// parse out textnodes to modify
def node = new groovy.util.XmlParser(false,false).parseText(property.value);
def textNodes = node["soapenv:Body"]["sam:getContactInfo"]["String_1"][0].children()
// modify
textNodes.clear();
textNodes.add( "test" + System.currentTimeMillis() );
// write back to string
def writer = new java.io.StringWriter();
def printer = new groovy.util.XmlNodePrinter( new PrintWriter( writer ));
printer.print( node );
// set property
property.setValue( writer.toString() )
-------------------------------------------------------------------------------------
What am I doing wrong? Should I have to set something before I run my script? I get this error even if I run the load test from the command line.
Also, is there a place I can go to for seeing working examples of groovy scripts inside SoapUI. I want to call different methods inside a Webservice and the inputs to successive webservice calls will be based on the responses to previous webservice calls.
Any help you can provide will be greatly appreciated.
Thanks,
Venkat