Forum Discussion

Pawel_K's avatar
Pawel_K
Regular Visitor
7 years ago

Transfer multiple xml nodes form Response to different SOAP request

Hello,

I have problem with all "exportItems" nodes form SOAP respond

         <exportItems>
            <ns2:id>0</ns2:id>
            <ns2:assetLogicalPath>DcNew</ns2:assetLogicalPath>
            <ns2:type>DOCUMENT_CLASS</ns2:type>
            <ns2:includeSubFolders>false</ns2:includeSubFolders>
         </exportItems>
         <exportItems>
            <ns2:id>0</ns2:id>
            <ns2:assetLogicalPath>DcNew2</ns2:assetLogicalPath>
            <ns2:type>DOCUMENT_CLASS</ns2:type>
            <ns2:includeSubFolders>false</ns2:includeSubFolders>
         </exportItems>
         <exportItems>
            <ns2:id>0</ns2:id>
            <ns2:assetLogicalPath>DcNew3</ns2:assetLogicalPath>
            <ns2:type>DOCUMENT_CLASS</ns2:type>
            <ns2:includeSubFolders>false</ns2:includeSubFolders>
         </exportItems>

 to request:

 

      <prom:CreateExportAssetsJob>
         <com:authContext>
            <com:UsernameToken>
               <com:domain>
                  <com:ident>
                     <com:name>${#TestSuite#name}</com:name>
                  </com:ident>
               </com:domain>
               <com:userId>${#TestSuite#userId}</com:userId>
               <com:password>${#TestSuite#password}</com:password>
            </com:UsernameToken>
         </com:authContext>
         <exportItems>
            <mod:id>0</mod:id>
            <mod:assetLogicalPath>DcNew</mod:assetLogicalPath>
            <mod:type>DOCUMENT_CLASS</mod:type>
            <mod:includeSubFolders>false</mod:includeSubFolders>
         </exportItems>
         <exportDirectory>${#TestSuite#exportDirectory}</exportDirectory>
      </prom:CreateExportAssetsJob>

 

and I'm stuck, I worte groovy script but he only transfer the first "exportItems" but i need to transfer all of then can someone help me with that:

 

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def child = groovyUtils.getXmlHolder("getAssetDependencies#Response")
def holder = groovyUtils.getXmlHolder("createExportAssetsJob#Request")
def node = holder.getDomNode("//exportItems")
node.appendChild(node.getOwnerDocument().importNode(child.getDomNode("//exportItems"), true))
holder.updateProperty()

 

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Would you mind providing full response and request?
  • PaulMS's avatar
    PaulMS
    Super Contributor

    Either get the parent of exportItems or getDomNodes for multiple items.

     

     

    def items = child.getDomNodes("//exportItems")
    items.each {item -> node.appendChild(node.getOwnerDocument().importNode(item, true)) }