Forum Discussion

vinuthakrishnam's avatar
14 years ago

Please provide the solution to Remove Empty node from Reques

Hi

We are facing problem in Removing Empty Node from Request. Please find the “OrderSubmission Request details” from the attachment for details about TestSuite and DataSource of the Request.

From the Soap Request the node named “onev:Migration” and ” onev:Add” needs to be removed from the request when we are not passing the attribute values inside these nodes.
We tried finding solution to this problem by adding following code in Groovy Script to remove “onev:Migration” node.

We have configured the Data source step, and fetching data from excel sheet. Now we want to remove the node “onev:Migration” if the attributes for the node are empty.
So we added a groovy script after the “Property Transfer” and before the execution of the “Request”.


Groovy Script code:

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def reqholder = groovyUtils.getXmlHolder('OneVuOrderDTH#Request');
reqholder.namespaces["onev"] = "http://ca.bell.tv.onevu2/OneVuOrder"

def val1 = reqholder.getNodeValue("//onev:OneVuOrderRequest/onev:OrderHeader/onev:OrderInformation/onev:Migration/onev:AccountNumber");

def filename="test.txt";
if(val1==null){

reqholder.remove("//onev:OneVuOrderRequest/onev:OrderHeader/onev:OrderInformation/onev:Migration");
reqholder.updateProperty();
}

But when we execute this, it is throwing “NullPointerException”. We also tried in the following way as well.

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def reqholder = groovyUtils.getXmlHolder('OneVuOrderDTH#Request');
reqholder.namespaces["onev"] = "http://ca.bell.tv.onevu2/OneVuOrder"

def val1 = reqholder.getNodeValue("//onev:OneVuOrderRequest/onev:OrderHeader/onev:OrderInformation/onev:Migration/onev:AccountNumber");

def filename="test.txt";
if(val1==null){

// def node = reqholder.getDomNode( "//onev:Migration" );
// node.parentNode.removeChild(node);
// reqholder.updateProperty();
}

With this we are not getting any exception but the node is not getting removed from the request.

Also find the SoupUI pro license from the attachment for details regarding the license file.

Please provide the solution to this problem.
No RepliesBe the first to reply