Solved! Go to Solution.
@alaedine - This should do the trick
NOTE: In my sample, am just updating the value and setting that xml object as the response.
var message = context.getVariable('request');
if (message && message.content) {
var xml = new XML(message.content);
var ns1 = new Namespace('ns1','http://ws.detaildossier.credit.traitement.com/');
var soap = new Namespace('soap','http://schemas.xmlsoap.org/soap/envelope/');
var body = xml.soap::Body;
// modify the text value of a specific node
var recupererDetailDossierCreditResponseObj = body.ns1::recupererDetailDossierCreditResponse;
var capitalRestantDuTextNode = recupererDetailDossierCreditResponseObj.return.responseDetailDossierCredit.capitalRestantDu.text();
//print("capitalRestantDuTextNode: "+capitalRestantDuTextNode);
capitalRestantDuTextNode.parent().setChildren('200');
//print(xml.toXMLString());
response.content = xml.toXMLString();
}
@alaedine - This should do the trick
NOTE: In my sample, am just updating the value and setting that xml object as the response.
var message = context.getVariable('request');
if (message && message.content) {
var xml = new XML(message.content);
var ns1 = new Namespace('ns1','http://ws.detaildossier.credit.traitement.com/');
var soap = new Namespace('soap','http://schemas.xmlsoap.org/soap/envelope/');
var body = xml.soap::Body;
// modify the text value of a specific node
var recupererDetailDossierCreditResponseObj = body.ns1::recupererDetailDossierCreditResponse;
var capitalRestantDuTextNode = recupererDetailDossierCreditResponseObj.return.responseDetailDossierCredit.capitalRestantDu.text();
//print("capitalRestantDuTextNode: "+capitalRestantDuTextNode);
capitalRestantDuTextNode.parent().setChildren('200');
//print(xml.toXMLString());
response.content = xml.toXMLString();
}
Whoo-hoo, love it! E4X solves it.
For other readers, you could ALSO solve this with an XSL, or ... I guess with a Java callout, like this one, which allows you to modify a single node in an XML document.
Which approach you choose depends on your preferences, which one is easiest to maintain and understand, etc.