Forum Discussion

saundap's avatar
11 years ago

getXMLHolder returns null.pointer

Hi,

I have a series of testSteps, starting at 0. Step 1 is my SOAP request, named 'Assess'. Step 2 is my groovyScript.

My script is attempting to get the XML extracted from step 1, but I consistently encounter a java.lang.NullPointerException when I attempt to log.info the value returned by the getXMLHolder method. I presume this means the code could not locate the Request I'm after.

Now, i'm able to confirm the Request has been generated and stored as I can access it via the context.expand method.

Does anyone have similar experience, is there something I'm missing fundamentally about the getXMLHolder method?

//Date: 22 November 2013
//Purpose: 'Output the <type:list-employee> contents of a request
//Note: This function is used in the XXXXX worksheet column XXXX
//By: Andrew Saunders - andrew.saunders@integrationQA.co.nz

//Step 1 - verify request and response are recorded
//Confirm if the Request is generated
//log.info ("...String_Request...is...." + context.expand('${Assess#Request}'))
//Confirm if the Response is generated
//log.info ("...String_Response...is..." + context.expand('${Assess#Response}'))

//Step 2 - set the request and response to a variable as an object
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )

//Get Request
requestHolder = groovyUtils.getXmlHolder("Assess#Request" )
log.info ("...requestHolder...is...." + requestHolder)
//Get Response
responseHolder = groovyUtils.getXmlHolder("Assess#Response")
log.info ("...responseHolder...is..." + responseHolder)

//Step 3 - extract node value
// define namespace
//requestHolder.declareNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/")
//requestHolder.declareNamespace("typ", "http://oracle.com/determinations/server/10.4/PAYE_Calculator/assess/types")
//XPath on Request
x = requestHolder.getNodeValue( '//*[local-name() = "list-employee"]' )
log.info("...x..." + x)


//Step 4 - write to file
//Set output file
def myOutFile = "//ed.ird.govt.nz/ir/users/south/17azs7/Documents/soapUI/Annual Returns-OPA/datapool/output/multiple_employee_request.xml"

//newline
n = System.getProperty("line.separator")

//write/append the request to output file
def f = new File(myOutFile)
f.append(x + n, "UTF-8")