Contributions
Re: How to add nodes for soapUI request,useing groovy?
Expected result <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"> <soap:Header> <m:Trans xmlns:m="https://www.w3schools.com/transaction/" soap:actor="https://www.w3schools.com/code/">234 </m:Trans> </soap:Header> <soap:Body> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <PRICE>10.90</PRICE> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <PRICE>9.90</PRICE> </CD> </CATALOG> </soap:Body> </soap:Envelope> Below is requst <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"> <soap:Header> <m:Trans xmlns:m="https://www.w3schools.com/transaction/" soap:actor="https://www.w3schools.com/code/">234 </m:Trans> </soap:Header> <soap:Body> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <PRICE>10.90</PRICE> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <PRICE>9.90</PRICE> </CD> <CD> <TITLE>Greatest Hits</TITLE> <ARTIST>Dolly Parton</ARTIST> <PRICE>9.90</PRICE> </CD> <CD> <TITLE>Still got the blues</TITLE> <ARTIST>Gary Moore</ARTIST> <PRICE>10.20</PRICE> </CD> </CATALOG> </soap:Body> </soap:Envelope>1.3KViews0likes1CommentAdd/remove elements from xml-request
How to remove single element from xml.Below is the code for specific element but i am not able to delete selected element from the xml and serialize xml. def slurped = new XmlSlurper().parseText(requestXML1) //grope of eliment size 4 def gropeOfEliments= slurped.'**'.findAll{ it.name() == 'licenseStatus' } //how to delete 3rd element and serialize with 3 eliments.640Views0likes1CommentRe: JDBCrequst from groovy script,After successful connection and query executed.How to set response .
licNum = con.rows("SELECT * from LICENSE where LICENSE_NUMBER='564767' ") I am getting data from data base all column values with below format useing jdbcRequst from groovy. [{LICENSE_ID=421, IS_ACTIVE=1, LICENSE_CLASS_ID=1, APPROVED_EVENT_DATE=null}] how to Set above Name and values to properties.784Views0likes1CommentJDBCrequst from groovy script,After successful connection and query executed.How to set response .
//query executed from script def con = Sql.newInstance("jdbc:oracle:thin:@vXXX:XXX", "XXX", "XXX", "oracle.jdbc.driver.OracleDriver") //Sucessfully Connected Database def respId = con.rows("SELECT CODE from STATUS where STATUS_ID = '22' " //Now getting proper response. Hear how to add response name value to Property from groovy script. //query executed from JDBCRequst from jdbc custom property i am seting values to PropertyStep //if i am run JDBCRequst with out script i can save the response in property asResponseAsXml with that property i can save values into property using script. def step = context.testCase.testSteps['Properties'] step.propertyNames?.each { step.removeProperty(it) } //Parent nodes like Result,ResultSet,Row dbdata.'**'.find{ //log.info it.name() it.name() == 'Row' }.childNodes().each { //log.info "${it}" def prop = step.hasProperty(it.name()) ? step.getProperty(it.name()) : step.addProperty(it.name()) //log.info prop prop.value = it.text() //log.info it.text() .863Views0likes3CommentsHow to add nodes for soapUI request,useing groovy?
Actual Requset. <root xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org"> <actors> <actor>Christian Bale</actor> <actor>Liam Neeson</actor> <actor>Michael Caine</actor> </actors> <foo:singers> <foo:singer>Tom Waits</foo:singer> <foo:singer>B.B. King</foo:singer> <foo:singer>Ray Charles</foo:singer> </foo:singers> </root> Expected request <root xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org"> <actors> <actor >Christian Bale</actor> <actor >Liam Neeson</actor> <actor >Michael Caine</actor> </actors> <foo:singers> <foo:singer>Tom Waits</foo:singer> <foo:singer>B.B. King</foo:singer> <foo:singer>Ray Charles</foo:singer> </foo:singers> <foo:singers> <foo:singer >Tom Waits</foo:singer> <foo:singer >Ray Charles</foo:singer> </foo:singers> </root>1.5KViews0likes4CommentsRe: How to add nodes for soapUI request,useing groovy?
Thank you for your reply. I tried with below code addNewNode = """ """" // new node inparseText format def root8 = new XmlParser().parseText( requestXML ) // converted request xml intoparseText for (item in root8){ for(test1 in item){ nodelist = test1.value() nodelist.add(addNewNode) } } log.info root8 String outxml = groovy.xml.XmlUtil.serialize(root8) I am able to append node but the problem was when i am serializing data in xml format, new node is on parsetext format.How to serialize new node. Any one help me on this..1.4KViews0likes0Comments