Awesome
16 years agoFrequent Contributor
appending nodes to request
hi all,
i have a "Create" customer soap request. when i create the soap object in version 2.51 of soapui, under the 'Form' tab for the request, lists all the enumerations available from the wsdl for the complexType "customer" which populates the "create" request.
i'm trying to create a groovy script that:
creates the soap "create" request and appends all the enumerations (nodes) available from the wsdl for the type "customer".
i saw your example using 'getDomNode': http://www.eviware.com/forums/index.php?topic=173.0
but i keep getting a groovy class error for 'dNode' last couple lines of code below..
thanks in advance!
/////
...
def testStepName="request_" + "create_customer_1"
//////Create TestStep Request
def interfaceName="SoapBinding";
def operationName="Create";
def op = testRunner.testCase.testSuite.project.interfaces[interfaceName].operations[operationName];
def config = com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory.createConfig( op, testStepName );
def newTestStep = testRunner.testCase.addTestStep( config );
//////SET REQUEST
def testStep = testRunner.testCase.testSteps[testStepName]
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(testStep.name+"#Request")
def xmlUtils = new com.eviware.soapui.support.xml.XmlUtils();
def sessionId = context.expand( '${Properties - SessionId#SessionId}' )
def PartitionId = context.expand( '${Properties: Username, Password, PartitionId#PartitionId}' )
def name_space = "<" + "urn:Record xsi:type=\"ns232:Customer\" xmlns:ns232=\"urn:object.soap.company.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
holder.declareNamespace("urn", "urn:soap.customer.com")
holder.declareNamespace("ns232", "urn:object.soap.customer.com")
holder.declareNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
dNode = holder.getDomNode("//urn:Create")
log.info "~~~~~~~~~~~~~" + root
// getDomNode("//urn:Create[1]")
holder.setNodeValue("//urn:Session[1]/urn:SessionId[1]", sessionId)
holder.setNodeValue("//urn:Create[1]/urn:PartitionId[1]", PartitionId)
// holder.namespaces["urn"] = "urn:soap.customer.com"
// holder.namespaces["ns232"] = "urn:object.soap.customer.com"
// holder.namespaces["xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
holder["//urn:Create"] = name_space
//newTestStep.getTestRequest().setRequestContent(holder.xml)
// holder.setNodeValue("//urn:Create[1]/urn:Record[1]/@xsi:type", "n232:Customer")
for( aField in allElements )
{
def the_value = 91919191
// def the_field = "//urn:Create[1]/urn:Record[1]/ns232:" + aField + "[1]"
// def the_field = dnode.ownerDocument.createElementNS( "http://schemas.xmlsoap.org/soap/envelope/", "urn:Create" );
// holder["//urn:Create"] = the_field //create node
// dNode.appendChild(the_field)
// the_field.appendChild( dnode.ownerDocument.createTextNode( aField ))
// holder.setNodeValue(the_field, the_value) //set node value
//holder.updateProperty()
newTestStep.getTestRequest().setRequestContent(holder.xml)
///// "Create" REQUEST
${Properties - SessionId#SessionId}
${Properties: Username, Password, PartitionId#PartitionId}
/////sample of nested nodes i need to append
AAAAAA
bobobobob
devnull@devnull.com
123 STREET
i have a "Create" customer soap request. when i create the soap object in version 2.51 of soapui, under the 'Form' tab for the request, lists all the enumerations available from the wsdl for the complexType "customer" which populates the "create" request.
i'm trying to create a groovy script that:
creates the soap "create" request and appends all the enumerations (nodes) available from the wsdl for the type "customer".
i saw your example using 'getDomNode': http://www.eviware.com/forums/index.php?topic=173.0
but i keep getting a groovy class error for 'dNode' last couple lines of code below..
thanks in advance!
/////
...
def testStepName="request_" + "create_customer_1"
//////Create TestStep Request
def interfaceName="SoapBinding";
def operationName="Create";
def op = testRunner.testCase.testSuite.project.interfaces[interfaceName].operations[operationName];
def config = com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory.createConfig( op, testStepName );
def newTestStep = testRunner.testCase.addTestStep( config );
//////SET REQUEST
def testStep = testRunner.testCase.testSteps[testStepName]
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(testStep.name+"#Request")
def xmlUtils = new com.eviware.soapui.support.xml.XmlUtils();
def sessionId = context.expand( '${Properties - SessionId#SessionId}' )
def PartitionId = context.expand( '${Properties: Username, Password, PartitionId#PartitionId}' )
def name_space = "<" + "urn:Record xsi:type=\"ns232:Customer\" xmlns:ns232=\"urn:object.soap.company.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
holder.declareNamespace("urn", "urn:soap.customer.com")
holder.declareNamespace("ns232", "urn:object.soap.customer.com")
holder.declareNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
dNode = holder.getDomNode("//urn:Create")
log.info "~~~~~~~~~~~~~" + root
// getDomNode("//urn:Create[1]")
holder.setNodeValue("//urn:Session[1]/urn:SessionId[1]", sessionId)
holder.setNodeValue("//urn:Create[1]/urn:PartitionId[1]", PartitionId)
// holder.namespaces["urn"] = "urn:soap.customer.com"
// holder.namespaces["ns232"] = "urn:object.soap.customer.com"
// holder.namespaces["xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
holder["//urn:Create"] = name_space
//newTestStep.getTestRequest().setRequestContent(holder.xml)
// holder.setNodeValue("//urn:Create[1]/urn:Record[1]/@xsi:type", "n232:Customer")
for( aField in allElements )
{
def the_value = 91919191
// def the_field = "//urn:Create[1]/urn:Record[1]/ns232:" + aField + "[1]"
// def the_field = dnode.ownerDocument.createElementNS( "http://schemas.xmlsoap.org/soap/envelope/", "urn:Create" );
// holder["//urn:Create"] = the_field //create node
// dNode.appendChild(the_field)
// the_field.appendChild( dnode.ownerDocument.createTextNode( aField ))
// holder.setNodeValue(the_field, the_value) //set node value
//holder.updateProperty()
newTestStep.getTestRequest().setRequestContent(holder.xml)
///// "Create" REQUEST
/////sample of nested nodes i need to append