Forum Discussion

Awesome's avatar
Awesome
Frequent Contributor
16 years ago

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
  • Awesome's avatar
    Awesome
    Frequent Contributor
    hi all,

    still can't seem to figure this out. anyone have any suggestions?

    thanks!
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    Could you please post the exact error message you are getting? Thank you!

    Regards,
    Dain
    eviware support
  • Awesome's avatar
    Awesome
    Frequent Contributor
    here's the error.

    is something missing from this example?:
    http://www.eviware.com/forums/index.php?topic=173.0

    thanks!

    "Tue May 19 19:36:09 PDT 2009:ERROR:groovy.lang.MissingPropertyException: No such property: dnode for class: Script1
      groovy.lang.MissingPropertyException: No such property: dnode for class: Script1
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
      at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:241)
      at Script1.run(Script1.groovy:108)
      at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:55)"
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    looks like you are just missing the "def" for dnode, ie replace

    dnode = ..

    with

    def dnode = ..

    (you need to define the variable..)

    Does that help?

    regards!

    /Ole
    eviware.com
  • Awesome's avatar
    Awesome
    Frequent Contributor
    hi Ole,

    tried that,
    def dNode =

    still same error...
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    shouldn't that be

    def dnode = ..

    (ie not with a capital n)

    anyhow.. can you show the entire script again with this modification if it still isn't working?

    regards!

    /Ole
    eviware.com