I am trying to append node to my request using xmlslurper
Service.appendNode{
ifx:DepAcctId{
if (acctId!="<!-->"){ifx:AcctId("123")}
}
}
This results in
<DepAcctId>
<AcctId>123</AcctId>
</DepAcctId>
I want it to append the namespace, like
<if:DepAcctId>
<ifx:AcctId>123</ifx:AcctId>
</ifx:DepAcctId>
Please help.
This is the exact code that I am using.
holderRequest = tsuite.getTestCaseAt(2).getTestStepByName(tcName).testRequest.getRequestContent()
request = new XmlSlurper(true,true).parseText(holderRequest).declareNamespace(v2:'http://www.fnf.com/xes/services/acct/acctinq/v2_1',
ifx:"http://www.ifxforum.org/IFX_150",soapenv:"http://schemas.xmlsoap.org/soap/envelope/", xes:"http://www.fnf.com/xes")
Service = request.'soapenv:Body'.'v2:AcctInqRq'
Service.appendNode {
ifx:DepAcctId {
if (acctId!="<!-->"){ifx:AcctId(acctId)}
if (acctType!="<!-->"){ifx:AcctType(acctType)}
if (BankInfo!="<!-->"){ifx:BankInfo(BankInfo)}
}
}
xmlBuilder = new StreamingMarkupBuilder()
writer = xmlBuilder.bind {
mkp.declareNamespace(soapenv:"http://schemas.xmlsoap.org/soap/envelope/",ifx:"http://www.ifxforum.org/IFX_150",
v2:"http://www.fnf.com/xes/services/acct/acctinq/v2_1",xes:"http://www.fnf.com/xes")
mkp.yield request
}
holderRequest = groovyUtils.getXmlHolder(XmlUtil.serialize(new StreamingMarkupBuilder().bind {mkp.yield request}))
log.info holderRequest.getXml()
tsuite.getTestCaseAt(2).getTestStepByName(tcName).getProperty("request").setValue(holderRequest.getXml())
The tags are getting added but without the ifx
namespace prefix.