Forum Discussion
agogna
15 years agoNew Contributor
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,
Abhi
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,
Abhi
Related Content
- 4 years agokrasnoludpauli
- 2 years agovericomms