Contributions
- 15 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.1KViews0likes0Comments
Re: Re: Dynamically Generate request XML
Thanks for pointing me in the right direction. So, I created groovy script. In the script, I expand properties derived from the database and then create an xml node and append it to the current request xml. Here is the code to create and append the xml node. //Create Node def xmlBuilder = new NodeBuilder() // Assign Values to the node def newNode = xmlBuilder.CreateMatterDate { CorrelationID('1234124' ) if(dateNameId ==null){ DateNameID( "xsi:nil":"true")} else{ DateNameID( dateNameId)} DateType(dateType) DateValue(dateValue) } //Append the node def node = new groovy.util.XmlParser(false,false).parseText(property.value); def textNodes = node["soapenv:Body"]["mat:MatterServiceRequest"]["MatterServiceInput"]["UpdateMatter"][0].children() textNodes.add( matterNode); textNodes.add( newNode); // write back to string def writer = new java.io.StringWriter(); def printer = new groovy.util.XmlNodePrinter( new PrintWriter( writer )); printer.print( node ); Is there a better way to define nillable attribute instead of using if else condition as I doing? I have tried "?." operator but that didn't work. Thanks, Abhi15 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.1KViews0likes0CommentsRe: Dynamically Generate request XML
I have to dynamically create request xml based on number of rows retrieved from database. for example .....> -- row 1 ? ? ... ... -- row 2 ? ? ... ... I am retrieving all the rows using datasource and running a query. Then I tried to insert new tags from the property transfer step using Property Transfer from declare namespace mat='http://xxxxxxxx/matterservice/'; insert ' ${Properties#CORRELATION_ID} ${Properties#MTTR_DT_NM_ID} ${Properties#MTTR_DT_TYPE_ID} ${Properties#DATE_VALUE} ' into //mat:MatterServiceRequest[1]/MatterServiceInput[1]/UpdateMatter[1]/row[1] Property Transfer to declare namespace mat='http://xxxxxx/matterservice/'; //mat:MatterServiceRequest/MatterServiceInput/UpdateMatter/CreateMatterDate But instead of inserting, it overwrites the existing values. I know I am doing something wrong as this step should be trivial. Can somebody point me in the right direction. Thanks, Abhi15 years agoPlace ReadyAPI QuestionsReadyAPI Questions3.5KViews0likes4Comments