August 31, 2019

Custom function in OIC

Using Libraries to Manage Functions for Integrations 


Knowledge :  👀 
Extension libraries provide a means to register and organise javaScript for use in integrations.Library functions are automatically available for you to drag from the Actions palette to your orchestration integrations.


In this blog we will see how to define custom function in OIC and then use it inside our Integration.

Use Case :
Our requirement is to convert date format "20-MAR-95" into this format "20-03-2095". As we don't have any function as of now present in OIC to full fill this requirement , so we will define a CUSTOM FUNCTION (in javascript) and later use this function in an Integration. 

Approach :
  1. Firstly, we will register the Libraries that is containing our CUSTOM JAVASCRIPT FUNCTION. Once it get registered , libraries functions are automatically available for us to drag and drop from Actions palette for orchestration Integrations.
  2. Secondly, we will use this custom function in one integration.
  3. Thirdly, Testing of Integration.

Lets see the steps in detail :

STEP 1:  
In OIC home page , click Libraries icon present inside the left Designer navigation bar.

  • Click the Register button in the tittle bar.


Save the below javascript code as ""convertDateFormat.js" in your local
system.
     
function convertDateFormat(date){  
var monthName = ["None","JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"];
var splitDate = date.split("-");
var convertedDate =  "20" + splitDate[2] + "/"+  String("00" + monthName.indexOf(splitDate[1])).slice(-2) + "/" +splitDate[0];  
return convertedDate;  
}

  • In the Register Library dialog box, click browse to select the above saved file "convertDateFormat.js" 
       Enter the below details :
                       
       *Name : ConvertDateFormat (you can enter any meaningful name) 
       Description : write some meaningful description & click create.
      



  • The libraries page will open , select convertDateFormat.js as shown in below image

  • select XPath , click Save and then close
Registration of libraries that contain our custom function "convertDateFormat" is completed. Now we can use this custom function in our integrations.




STEP 2 :  
Now let's create an Integration to use above registered custom function "convertDateFormat"
  • From the left Designer navigation bar present in OIC home page, click Integration and then click Create

       Select App Driven Orchestration


Knowledge :  👀
App Driven Orchestration ? : It enables you to create an integration that uses an event or business object to trigger the integration. In laymen's terms  - you have to pass some inputs to trigger the app driven orchestration integrations.

Scheduled Orchestration ? : It enables you to create an integartion that uses a schedule to
trigger the integration instead of an adapter. After designing such integration, you can schedule when to run it.


Enter the below details and then click Create :

*What do you want to call your Integration? - write some meaningful name
*What can this Integration do? - write some meaningful description


  • Search for the REST connection name 'RESTConnection' and Select it.
     ( You can access this blog to configure this REST connection )

 Enter the below details and click Next - [as shown in below image ]

*What do you want to call your endpoint ? : write any meaningful name
*What is the endpoint's relative resource URI ? :  write  /date   
 (you can give any meaning full word with "/" )       
          
*What action do you want to perform on the endpoint ? : Select POST
&
Select Configure a request payload for this endpoint
Select Configure a response payload for this endpoint


Select JSON Sample and then click inline to add request payload
[as shown in below image ]



Enter sample JSON →   {"Input Date Format" : ""}  and click OK and then click Next



Similarly configure response payload :
Enter sample JSON →   {"Output Date Format" : ""}  and click OK and then click Next.

Click Done.

  • Open the Mapper by clicking Edit icon.

Knowledge :  👀 
Map ? : It Enables you to add ad-hoc mappers to the integration.

           
Click the icon as shown in below image to see your custom function
"convertDateFormat" which we have configured in STEP 1.


 Right click at response column and then select Create Target Node

Now drag and drop the custom function from left pane inside popup window
and then drag and drop the request column inside this function call and then
click Validate and then Close.(as shown in below image )




Enable tracking by clicking Hamburger sign Menu icon and then click Tracking 

Map the request column as tracking variable and then click Save and Close.


Knowledge :  👀 
Assigning Business Identifiers for Tracking Fields ? : Business identifiers enable you to track payload fields in messages during runtime.You must assign business identifiers before you can activate an integration.

Click Save and Close. Your Integration is ready to TEST.



          


TESTING STEPS:   
  • Activate the above integration 
   
        
         Click on endpoint URL
       

         Copy the endpoint URL 



  • Now, Open SoapUI tool (5.5.0) to Run the above integration:



Knowledge :  👀 
SoapUI? :  It is an open source web service testing application.


Click on REST ,Then Paste the above copied endpoint URL and then click OK



  • Configure the REQUEST PAYLOAD ( as shown in below image):
       Method : POST
       Media Type : application/json

       paste below request sample in request payload box
    
         {"Input Date Format":"20-MAR-95"}

              Authorization : add Basic authorization (enter your OIC userid 
      and password )
      Click RUN Button , You will see Output in JSON fromat.


August 14, 2019

Read file using FTP adapter in OIC

USE CASE : 


In this blog we will see how to READ a csv file records from FTP server directory. Inside this POC we will develop an integration which will take two INPUTS → File_Name, Directory_Path and will give file records as OUTPUT.

INPUT :


FTP .CSV FILE :

OUTPUT :






Lets see the development steps in detail:

STEP 1: In the Designer tab, click Integration and then click Create



      Select App Driven Orchestration



       Enter the below details and then click Create :

                   *What do you want to call your Integration? - write some meaningful name
                   *What can this Integration do? - write some meaningful description



STEP 2 : Search for the REST connection name ' RESTConnection ' and Select it.
                 ( You can access this blog to configure this REST connection )

       Enter the below details and click Next - [as shown in below image ]

       *What do you want to call your endpoint ? : write any meaningful name
              *What is the endpoint's relative resource URI ? :You can give any meaningful
                word with "/"
                Example :    /readFile
              *What action do you want to perform on the endpoint ? : Select POST
        &
        Select Configure a request payload for this endpoint
                Select Configure a response payload for this endpoint
  

   **Download & Save this below Schema as ReadFileRequest.xsd in your local system

     Download ReadFileRequest.xsd 

       Choose the above saved schema ReadFileRequest.xsd in next window and click 
       NEXT
      [as shown in below image ]


   **Save this below Schema as ReadFileResponse.xsd in your local system

        Download ReadFileResponse.xsd

       Choose the above saved schema ReadFileResponse.xsd in next window and click 
       NEXT

      [as shown in below image ]

     Click Done
      

STEP 3 : Search for the FTP connection name → " FTP_Test " which we have created in
                in the previous blog.



         Enter below details and then click NEXT :
                   *What do you want to call this endpoint : write any meaningful name
                   *What does this endpoint do : write meaningful description



         Enter the below details and then click NEXT :
                      *Select Operation : select Read a File
           *Select a Transfer Mode : select ASCII
            Input Directory : write /  (as shown in below image )
                        (here you can provide your directory path from where
             you want to read file)
                       File Name : Write EMP_1.csv
           (here you have to write file name which you want to read)



           Select Sample delimited document (e.g CSV ) and click Next 




         Paste the below text in notepad or any text editor tool and save it as 
        Employee.csv

Emp_Id,Emp_FirstName,Emp_LastName,Emp_Designation,Emp_DC_Location


            Configure the below details and then click NEXT :

                       *Choose File : select the above saved file Employee.csv
                       *Enter the Record Name:Employee (you can write any meaningful name)
                       *Enter the Recordset Name : EmployeeDetails
                         (you can write any meaningful name)

                    **Make sure to change the datatype of Emp_Id to Integer
                      (as shown in below image)

     Click Done 



STEP 4 : Open the FTP adapter mapper and map the columns accordingly 
                (as shown in below image )






STEP 5 : Now open the response mapper 
             
           and map the columns accordingly (as shown in below image )
           
          **Make sure to map the Employee node also to configure for each




       you can see the for each function by clicking on Advance tab



    click Validate and Close the mapper.

STEP 6 : Add the Tracker for your Integration :
              Right click on Hamburger sign and then click on Tracking


            Map File_Name as tracking variable and then click Save
             (as shown in below image )


STEP 7 : Click Save and then Close the integration. Your Integration is ready to test.





TESTING STEPS :


In below Step 1 we will put the file in FTP server directory (at / directory)which we want to read and in Step 2 we will RUN the integration using SoapUI tool.


STEP 1:


   Open FileZilla Tool :

   Enter the FTP Connection details (you can see the previous blog for FTP Credentials)


   Click OK

    

   Save the below .csv file as EMP_1.csv in your local system 

Emp_Id,Emp_FirstName,Emp_LastName,Emp_Designation,Emp_DC_Location
1001,Rohit,Kuma,System Engineer,Delhi
1002,Rahul,Kumar,System Engineer,Pune

or

Download EMP_1.csv file

            Upload the above EMP_1.csv file from your local system to FTP  server  
            directory (as shown in below image)



NOW....

STEP 2 :

    Activate the Integration 



      Click Activate


     Click on Endpoint URL  (as shown in below image )




     Copy the Endpoint URL 



     Open SoapUI tool (5.5.0):




  • Click on REST
  • Then Paste the above copied endpoint URL and then click OK



  • Configure the REQUEST PAYLOAD ( as shown in below image):
       Method : POST
       Media Type : application/xml
      Download application/xml payload

     paste the above downloaded SoapUI payload in application/xml payload (as shown in below
     image)




            Authorization : Add Basic autorization 



                                  Enter your OIC userid and password

  

     Now click on RUN button. You will get the read file Response 

      **Note you may see Socket Time out Error in SOAPUI with empty Response
          payload.  
          (This issue occurs  when the server takes more than one minute to respond)



    To resolve this issue,Open SoapUI -> Preferences ->HTTP Settings ->Update
      Socket Timeout(ms) to 600000 and then click Ok


   Now if you again hit the RUN button you will successfully able to see the response.




Thank You !