kanchankumbhalk
13 years agoOccasional Contributor
How do you add a new element to the request using Groovy
Hi
I need to add a new element / node in the request xml dynamically.
I am trying the following groovy script
but I get the error
groovy.lang.MissingMethodException: No signature of method: [Lorg.w3c.dom.Node;.getOwnerDocument() is applicable for argument types: () values: [] error at line: 45
I need to add a new element / node in the request xml dynamically.
I am trying the following groovy script
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
//def xmlUtils = new com.eviware.soapui.support.xml.XmlUtils();
def functionAreas = context.expand( '${DataSource#FunctionAreas}' )
def compensationType = context.expand( '${DataSource#CompensationType}' )
log.info "${compensationType}"
log.info "******************"
def xmlFragment = context.expand( '${Properties#xmlFragment}' )
groovyUtils.setPropertyValue('Properties', 'FunctionalArea',"<list><key>Functional Area</key><value>${functionAreas}</value></list>")
groovyUtils.setPropertyValue('Properties', 'CompensationType',"<list><key>Compensation Type</key><value>${compensationType}</value></list>")
def holder = groovyUtils.getXmlHolder("matchRanking - Request 1#Request")
def node = holder.getDomNodes("//ran:matchRanking")
def nodeCount = node.length
log.info "nodeCount = " + nodeCount
// create a new Element in the Document
def requestDoc = node.getOwnerDocument()
def oneElement = requestDoc.createElement(node.getNamespaceURI(), "candidatePropsList")
def childNode = holder.getDomNodes("//candidatePropsList")
def childNodeCount = childNode.length
log.info "childNodeCount = " + childNodeCount
but I get the error
groovy.lang.MissingMethodException: No signature of method: [Lorg.w3c.dom.Node;.getOwnerDocument() is applicable for argument types: () values: [] error at line: 45