Using the iWay Enable Application Programming Interface for Advanced Integration

The iWay Enable Application Programming Interface (API) allows for advanced integration using a Web API.

The following examples show two ways to integrate with iWay Enable, using the Web API, JavaScript Object Notation (JSON), and XML. These examples allow you to override the configurations and customize the widgets without using the iWay Enable Wizard in the iWay Service Manager Administration Console. The JSON and XML objects can also be served locally, reducing the number of requests passed to iWay Enable.


Top of page

Example: Integrating With iWay Enable, Using an Override

You can save the following code to an HTML file, to be served as a portlet. The iWay Service Manager Administration Console guides you through the creation of a portlet. Click Tools, Resources, and the Portlets tab, as shown in the following image.

Alternatively, you can copy the code for direct use in your composite application.

<html>
     <head>
     <script language="JavaScript"
          src="http://localhost:[port]/ism/enable-res/FusionCharts.js"></script>
     <script type="text/javascript"
          src="http://localhost:[port]/ism/enable-res/enable.js"></script>
     </head>
     <body>
     <div id="msgcount"></div>
     <script type="text/javascript">
          var url; // set to the JSON URL provided by the Enable Wizard
          var context; // set as your iSM context: http://localhost:[port]/ism
          var debug = 0; // 0=No debug, 1=Debug
          var divId = "msgcount"; // DIV id of the element in which to render
                                  // the chart
          var req;
          if (window.XMLHttpRequest) // code for all new browsers
          {
               req=new XMLHttpRequest();
          }
          else if (window.ActiveXObject) // code for IE5 and IE6
          {
               req=new ActiveXObject("Microsoft.XMLHTTP");
          }
          else
          {
               alert("Your browser does not support XMLHTTP.");
          }
          req.open("GET", url, /*async*/false);
          req.send(/*no params*/null);
          // deserialize the JSON string returned
          var agAtts = eval('(' + req.responseText + ')');
          // override the width and height
          agAtts.width = 120;
          agAtts.height = 100;
          var ag = new iwenable.AngularGauge(context,divId,debug,agAtts);
          ag.render();
     </script>
     </body>
     </html>

Top of page

Example: Integrating With iWay Enable, No Override

The code in the following example accomplishes the same objective as the code in the previous example, but the code in this example does not allow you to override the values for the style.

var url; // set to the XML URL provided by the Enable Wizard
var context; // set as your iSM context: http://localhost:[port]/ism
var divId = "msgcount"; // DIV id of the element in which to render the chart
var ag = new iwenable.AngularGauge(context,divId);
ag.render(url); // set the url

iWay Software