August 7, 2019

Write file using FTP adapter in OIC

Use case :

In this blog we will see how to perform Write operation using FTP adapter in OIC. In this POC we will develop an integration which will take some Inputs and that inputs will get saved as .csv file in remote FTP location.






Lets see the development steps in detail :

STEP 1: In the Designer window 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



Knowledge :  👀 
Packages ? : You can group one or more integrations into a single structure called a package to easily import and export them to and from OIC service. Packages being optional, integration do not be a part of them. At least one integration is needed for a package to exist.

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 :    /employeeDetails
              *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




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



     Choose the above saved schema "EmployeeDetails.xsd" in next window and then 
      click NEXT.

        [as shown in below image ]

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



            Enter sample JSON →   {"Response" : "" }  and click OK



              Click NEXT


           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 Write File
                      *Select a Transfer Mode :  select ASCII

                      *Output Directory :  write /  (as shown in below image )
                       (here you can provide your directory path where you want to generate 
                        the file)

                      *File Name Pattern : write EMP_%SEQ%.csv
                      (here you can provide any meaningful file name)




                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 )

             **Make sure to map the Employee node also to configure for each



             you can see the foreach function by clicking on Advance tab 



          click Validate and close the mapper.



STEP 5 : Now open the response mapper 



            Right click on Response and then select Create Target Node


         Write "Success" in editor window and 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 Emp_Id as tracking variable and then click Save
                (as shown in below image )



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.

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







TESTING STEPS :

Activate the Integration and copy the Endpoint URL 





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 the xml file & paste the same in SoapUI)

Download application/xml file
                  Authorisation : Basic

Now click on RUN and if everything works fine you will see RESPONSE message in RESPONSE Payload of SoapUI as shown in below image 


OR You can test using Postman Tool :



The file will get generated in your FTP directory. If you want to see the file 

Open FileZilla Tool :


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




Click OK

file got generated in "/" directory of FTP 



Download the file to you local system and opened it. You will see the below data 



Thanking You !

No comments:

Post a Comment

If you have any doubts, Please let me know.