With JavaScript Connector service, you can integrate plain JavaScript services to applications in Kony Fabric.
You can upload custom JavaScript files to Kony Fabric. Using JavaScript connectors, you can easily create server side code and make it available as operations. The JavaScript file must contain functions that the user wants to be made available as operations, along with other supporting functions. Please view the Limitations section for details of the structure for JavaScript function definitions.
For more details about the sample JavaScript code, refer to JavaScript Sample Code for Preprocessor and Postprocessor.
Based on JDK version supported by the Kony Fabric Installer, the JavaScript Connector uses the following JavaScript engines:
To configure a JavaScript connector, follow these steps:
From the Service Type drop-down list, select JavaScript.
From the Versions drop-down list, select the required version. You can select only one version of the service.
The system allows you to upload more than one JS file at Specify the Javascript libraries.
JavaScript files, once uploaded, will be available across the Kony Fabric console. They cannot be deleted, only unlinked. You can unlink uploaded JS files by clicking the Unlink button.
Note: You can also add operations by following these steps:
- Click the Operations List tab.
- From the tree in the left pane, click Add > Add New Operation, shown below:
Note: To use an existing integration service, refer to How to Use an Existing Integration Service.
Click ADD OPERATION to create operations with the selected functions.
The new operations are created and listed under the Configured Operations.
Operations name are auto-generated in the format : <Name-of-the-JS-file>_<function-name>. For example, sample_function_addTwoNumbers
Click the operation. In the Operation Modal tab, follow these steps:
The tab contains the request input, response output, and advanced sections. The input values are data types, scope, and format types. By default, the system will display the Request Input tab.
Note: You can add an entry by clicking the Add button if entries for the input and the output tabs do not exist.
You can also delete an entry. Select the check box for an entry, and then click the Delete button.
Configure the parameters for the preprocessor and postprocessor to filter the request and response objects for your business requirements. You can only specify custom JavaScript code for preprocessor and postprocessor.
<serviceInputParams>
, <request>
, <response>
and <result>
.
You can use these objects and their corresponding methods directly in JavaScript code.
For a sample JavaScript code, refer to JavaScript Sample Code for Preprocessor and Postprocessor.
The step allows you to further filter the data received from a service call.
Note: You can add an entry by clicking the Add Parameter button if entries for the input and the output tabs do not exist.
- To make duplicate entries, select the check box for the entry, click Copy, and then click Paste.
- To delete an entry, select the check box for an entry, and then click the Delete button.
Select request or session in the Scope field. By default, this field is set to Request.
Note: The Response Output tab is not honored in JavaScript Connector.
In JavaScript service, the response (output) from a backend is not parsed based on the response values. The complete response from the backend is sent to the client device.
If you click Cancel, the Operation Modal tab will close without saving any information.
Note: To add more operations for your JavaScript service, repeat Step 3 through Step 4.
Nashorn does not support some common JavaScript libraries and global JavaScript functions, such as jQuery, setTimeout, setInterval or XMLHttpRequest. However, it provides an alternate mechanism to perform the same operation. You can invoke the required functionality using Java for such cases. For example, consider the XMLHttpRequest API. Since Nashorn does not support this API, you will need to use Java to perform the required operations. You can use URLConnection java class or HttpClient API to achieve the same goal.
function abc() { … }
Copyright © 2020 Kony, Inc. All rights reserved. |