The integration service web page contains links to the JavaScript client API file, details of the JavaScript client API methods, details of the errors that might be returned from the integration service, and sample code that a JavaScript developer can add to a JavaScript application to call the JavaScript client API.
For each method, there is a description, a list of the input and output objects, and any faults that are defined. The following image shows an example of a method, with the names of the input and output objects, and the names of two defined faults.
For information about the JSON conventions that are used in the JavaScript client API, and the limitations that are associated with the use of the API, see JSON conventions for calling an integration service by using a JavaScript client API.
/* Uncomment these lines if you are developing in a Node.js environment.
require("http");
require("./creditReport");
IBMIntegration.creditReport.IBMContext.hostname = "myhost.company.com";
IBMIntegration.creditReport.IBMContext.port = 7800;
*/
/* Uncomment these lines and put them in the <head> element of your HTML if you are developing in a browser environment.
<script type="text/javascript" src="/creditReport?resource=dojo.js"></script>
<script type="text/javascript" src="/creditReport?resource=creditReport.js"></script>
*/
/* This is an example of the output JSON variable.
var getApprovalResponseVar =
{
"approval" :
{
"customer" :
{
"id" : "idValue" ,
"fName" : "fNameValue" ,
"lName" : "lNameValue"
} ,
"account" :
{
"sortCode" : "sortCodeValue" ,
"accNo" : "accNoValue" ,
"accType" : "accTypeValue"
} ,
"approved" : true
} ,
"balance" :
{
"customer" :
{
"id" : "idValue" ,
"fName" : "fNameValue" ,
"lName" : "lNameValue"
} ,
"account" :
{
"sortCode" : "sortCodeValue" ,
"accNo" : "accNoValue" ,
"accType" : "accTypeValue"
} ,
"balance" : 1.0
}
};
*/
/* This is an example of the unexpected error JSON variable.
The penultimate property contains the actual exception thrown in IIB.
Search the product documentation for 'exception list structure' to view the different types of exceptions and their contents.
var unexpectedErrorVar =
{
"errName" : "Exception",
...
"Label" : "{Label of the node where the exception occurred}",
...
"{Exception name}" : {// penultimate property
... exception details ...
},
"Input" : {
... input message that caused this exception ...
}
};
*/
/* This is an example of the fault JSON variable.
var getApprovalFault1Var =
{
"errName" : "getApprovalFault1",
"getApprovalFault1" : "getApprovalFault1Value"
};
*/
/* This is an example of the fault JSON variable.
var getApprovalFault2Var =
{
"errName" : "getApprovalFault2",
"getApprovalFault2" : {
"identifier" : "identifierValue" ,
"message" : "messageValue"
}
};
*/
/* This is an example of the input JSON variable. */
var getApprovalVar =
{
"customer" :
{
"id" : "idValue" ,
"fName" : "fNameValue" ,
"lName" : "lNameValue"
} ,
"account" :
{
"sortCode" : "sortCodeValue" ,
"accNo" : "accNoValue" ,
"accType" : "accTypeValue"
}
};
IBMIntegration.creditReport.getApproval( getApprovalVar, function( err, getApprovalResponseVar ){
if (err) {
console.log(" Failure for IBMIntegration.creditReport.getApproval() ");
var errName = err.errName;
if ( errName == "getApprovalFault1") {
console.log("Fault getApprovalFault1 occurred.");
}
else if ( errName == "getApprovalFault2") {
console.log("Fault getApprovalFault2 occurred.");
}
else if ( errName == "Exception") {
console.log("Unexpected error occurred.");
//To see the full details of the error, use JSON.stringify(err);
//To retrieve only the exception, navigate to the penultimate property within the error
var keys = Object.keys(err);
console.log("Exception type: " + keys[keys.length-2]);
}
}
else {
console.log(" Success for IBMIntegration.creditReport.getApproval() ");
}
} );