February 3, 2021

Integrating Oracle Digital Assistant with Oracle Analytics Cloud via SOAP webservice

In this post, you will see the integration between ODA (Oracle Digital Assistant) and OAC(Oracle Analytics Cloud) dashboard.

Creating OAC dashboard:

  • For the integration, we created a sample OAC dashboard as shown in the below screenshot
  • Soap services are exposed for the dashboard
Changes required to the ODA custom component:
  • Add the "soap" module to the ODA custom code node project
  • In the component javascript file, uses the below program code.  Where,  
    • createClient() is the method to create a connection to the soap WSDL which expects WSDL URL
    • Once the client is created, then you can use the methods in the Webservice
    • For example, logon() is a method that takes the user credentials as input arguments and returns a unique session  d which can be used in the further requests
    • Also in the below example, another method executeXMLQuery() is used which also part of the WSDL which expects an XML as input.
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();
        });
});
});

No comments:

Post a Comment