Contributions
Re: Excel to XML generation using groovy script in SOAP UI
Hi Rao, Thank you for your response and sharing the groovy documentation. Below is the issue details and still looking for hint to fix this. I am trying to build the xml by reading the data from excel file. Below is the tag hierarchy followed in excel and same has to be created in xml format. Sample 1: Level 1: Business Data Level 2: CONTACT Level 3: KontoAntrag Level 4: Starteinzug tns1:BusinessData/tns1: CONTACT/tns1:KontoAntrag/tns1:Starteinzug Sample 2: Level 1: Business Data Level 2: CONTACT Level 3: Starteinzug Level 4: BetragStarteinzug tns1:BusinessData/tns1: CONTACT/tns1:Starteinzug/tns1:BetragStarteinzug In the above two samples you can notice tag name 'Starteinzug' appears at level 4 in first one and at level 3 in another sample. As field ‘Starteinzug’ exists both at parent node of ‘CONTACT’ and one at child node for the field ‘KontoAntrag’, method CheckAndUpdateNode internally calls checkAndCreateNode method to create a field ‘Starteinzug’ and we are facing below overlapping prototypes exception error. groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method com.eviware.soapui.support.XmlHolder#. Cannot resolve which method to invoke for [null] due to overlapping prototypes between: [interface org.apache.xmlbeans.XmlObject] [interface org.w3c.dom.Node] error at line: 2428 Thank you!1.7KViews0likes1CommentExcel to XML generation using groovy script in SOAP UI
I am facing issue while reading excel file and generating XML strtcutre using groovy scripting. Please advise how can we handle where parentnode(Startmap) and child node(Startmap) has same name. //tns1:BusinessModel/tns1:CONTACT/tns1:Address/tns1:Startmap //tns1:BusinessModel/tns1:CONTACT/tns1:Startmap/tns1:BudgetPrice Script: def CONTACTNodeXPath = "//bpm:BusinessModel/bpm:CONTACT" //Check and Create Startmap checkAndCreateNode(holder, CONTACTNodeXPath, "Startmap") UpdateStartmapNode(holder, dFormatter, sourceRow, fEval) //Check and Create Address checkAndCreateNode(holder, CONTACTNodeXPath, "Address") UpdateAddressNode(holder, dFormatter, sourceRow, fEval) void checkAndCreateNode(XmlHolder holder, String parentXPath, String nodeName) { def parentNode = holder.getDomNode(parentXPath) log.info ("<R> value of parentnode:"+parentNode) def parentNodeHolder = new XmlHolder(parentNode) //log.info ("<R> value of parentNodeHolder:"+parentNodeHolder) parentNodeHolder.namespaces["bpm"]="http://emra.corp.net/ecm/bpm" def requestDoc = parentNode.getOwnerDocument() log.info ("<R> value of requestDoc:"+requestDoc) def childNode = parentNodeHolder.getDomNode("//bpm:" + nodeName) log.info ("<R> value of childNode:"+childNode) if(childNode == null) { childNode = requestDoc.createElementNS(parentNode.getNamespaceURI(), nodeName) log.info ("<R> value of childNode inside if:"+childNode) parentNode.appendChild(childNode) } } void CheckAndUpdateNode(XmlHolder holder, String parentXPath, String nodeName, String nodeValue) { checkAndCreateNode(holder, parentXPath, nodeName) holder[parentXPath + "/bpm:" + nodeName] = nodeValue log.info ("<R> value of nodeValue :"+nodeValue) } void UpdateAddressNode(XmlHolder holder, DataFormatter dFormatter, XSSFRow sourceRow, XSSFFormulaEvaluator fEval) { //Updating the values of Nodes under BusinessModel/CONTACT/Address def updateAddressNodeXPath = "//bpm:GenerateDocumentRequest/bpm:BusinessModel/bpm:CONTACT/bpm:Address" CheckAndUpdateNode(holder, updateAddressNodeXPath, "Startmap", dFormatter.formatCellValue(sourceRow.getCell(1286), fEval)) } void UpdateStartmapNode(XmlHolder holder, DataFormatter dFormatter, XSSFRow sourceRow, XSSFFormulaEvaluator fEval) { //Updating the values of Nodes under BusinessModel/CONTACT/Startmap def updateStartmapNodeXPath = "//bpm:BusinessModel/bpm:CONTACT/bpm:Startmap" CheckAndUpdateNode(holder, updateStartmapNodeXPath, "BudgetPrice", dFormatter.formatCellValue(sourceRow.getCell(1291), fEval)) } Error: An error occurred [Ambiguous method overloading for method com.eviware.soapui.support.XmlHolder#<init>. Cannot resolve which method to invoke for [null] due to overlapping prototypes between: [interface org.apache.xmlbeans.XmlObject] [interface org.w3c.dom.Node]], see error log for details1.8KViews0likes6Comments