var soap = require('soap');
var url = 'https://XXXX-XXXXXXXX-ld.analytics.ocp.oraclecloud.com/analytics-ws/saw.dll/wsdl/v12';
var args = { name: 'username@oracle.com', password: "password" };
soap.createClient(url, function (err, client) {
client.logon(args, function (err, result) {
var sid = result.sessionID.$value;
console.log(sid);
rPath = "/shared/COVID19NL/Covid19NL";
var xmlQueryArgs = {
report: { reportPath: rPath },
outputFormat: "",
executionOptions: { async: '', maxRowsPerPage: '', refresh: '', presentationInfo: '', type: '' },
sessionID: sid,
reportParams:{variables:[{"name":"varCity","value":"Amsterdam"}, {"name":"varMonth","value":"Apr"}]}
};
var xmlResult = "";
var transition = "success";
var filteredRows = [];
client.executeXMLQuery(xmlQueryArgs, function (err, result) {
if (err) {
transition = "fail";
console.log(err.body);
conversation.reply(err).transition(transition);
done();
return;
}
xmlResult = result.return.rowset.$value;
var convert = require('xml-js');
var options = { compact: true, ignoreComment: true, spaces: 4 };
var resp = convert.xml2json(xmlResult, options);
var rows = JSON.parse(resp).rowset.Row;
if (rows && rows.length > 0) {
filteredRows = rows;
transition = "success";
console.log(filteredRows);
}
else {
transition = "none";
}
conversation.transition(transition);
conversation.variable('resultRows', filteredRows);
done();
});
});
});