Tuesday, 5 May 2020

Import JavaScript libraries / jar to OIC Integration and build custom function

Summary:
In this blog i'm going to explain the procedure to import JavaScript libraries into the Oracle Integration Cloud (OIC) - Integrations and build custom solutions.

Use Case:
Sometime in projects there would be requirement for which there won't be any out of the box solution provided in OIC, So in such cases we can make use of java script libraries and import them to OIC and build custom solutions.

In this blog i'm going to show you how to achieve AES encryption using JavaScript libraries in OIC as an example to show library import.


Assumption:
1. OIC instance is already configured in Oracle Cloud and the environment should be up and running


Let's begin by first creating a jar containing AES JavaScript libraries and the JavaScript file containing our custom function

Steps to create jar containing JavaScript files:
1. Import and save below mentioned JavaScript libraries into your local computer
     i. AES.js
    ii. crypto-js.min.js
   iii. enc-utf8.min.js


 NOTE: Highlighted libraries are to be imported from their source or from GitHub repository.

2. As shown in above screenshot we need to write our custom JavaScript function in the file 'encryptAndDecryptMessage.js' as shown below as per the OIC library coding specification

   

3. Post writing custom function we may need to zip all 4 .js files (3 js library files and 1 custom js function file) as a jar using below command

         jar -cvf EncryptDecrypt.jar *.js

4.  EncryptDecrypt.jar will now be created in your local computer


5.  Login to OIC Integrations instance and then click on Libraries and then click on register
     



Select below option before saving the JavaScript function
    

   


5. Now goto any of your integrations and the custom function created in earlier steps will now be listed under user functions
    


   

Hope this blog helped you with the procedure to import JavaScript libraries or to create custom functions in OIC .

Let me know in comments section for any queries.


Know Yourself Blogs...

3 comments:

  1. jar -cvf EncryptDecrypt.jar *.js error out with message
    Exception in thread "main" java.lang.NoClassDefFoundError: jar.

    ReplyDelete
  2. .js files that you have used when added now functions are not usable. input and out put parameters don't get defined except the custom ones.

    ReplyDelete
  3. can u come up with a you tube video with integrations to COSMOS DB?

    ReplyDelete

Access Microsoft Outlook email using Outlook Version 2.0 API

Summary: This blog demonstrates the steps involved to access Microsoft Outlook email using Outlook Version 2.0 API's. Use Cas...