File And FTP Adapters
In this article we will discuss various aspects and features of File Adapers and FTP Adapters. These adapters are mostly used in projects which deal with data transfer activities like interfacing with legacy systems.
File and FTP Adapters
These are fairly simple to understand. These can handle various files viz. XML,Delimited, Fixed positional, Binary data etc. File Adapters can perform read and write operation. For inbound/read transactions we need to setup polling frequency for a given adapter instance. One adapter can perform one operation hence if we need to perform both reading and writing the file then we need to create two adapters in a BPEL/ESB project.
Lets develop one example using multiple file adapters viz.
1.ReadEmpDataFile - This adapter will read csv data files containing employee and dept information in one file
2.WriteEmpFile- This adapter will write employee data file from employee portion of input data file
3.WriteDeptFile - This adapter will write dept data file from dept portion of input data file
ReadEmpDataFile Adapter will need Receive Activity which will accept input from ReadEmpdataFile Adapter while Write Adapters will need Invoke Service.
Drag the file adapter service from Component pallet to Services Section of BPEL Project Designer.
As discussed we can perform one operation at a time using file adapter, so select Read File Operation
Specify the directory path for reading and archiving files. Make sure this path exists on the machine where SOA Suite is installed.
Specify the Name Patterns for files being read.
Since this is Read File Operation, we will have to specify the polling frequency.
This step defines the structure of the messages being read. We can specify the pre-existing XSD (XML Schema Definition) or DTD (Document Type Definition) or Define the schema based on CSV files by clicking Define Schema for Native Format
After Clicking Define schema following screen appears which creates XSD representation of native formats like CSV, TXT etc.
We can select various file types like Delimited, Fixed length, DTD
em_dept.csv contains data in following format
"EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO","DEPTNO_1","DNAME","LOC"
"7782","CLARK","MANAGER","7839","09-JUN-81","2450","","10","10","ACCOUNTING","NEW YORK"
With this Adapter Configuration is complete and it will automatically create a partner link."7782","CLARK","MANAGER","7839","09-JUN-81","2450","","10","10","ACCOUNTING","NEW YORK"
Follow the similar steps mentioned above to create two more file adapters for write operation viz, WriteEmpFile and WriteDeptFile
For WriteEmpFile adapter use employee CSV file in following format
"EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO"
"7369","SMITH","CLERK","7902","17-DEC-80","800","","20"
"7369","SMITH","CLERK","7902","17-DEC-80","800","","20"
For WriteDeptFile use Department CSV file in following format
"DEPTNO","DNAME","LOC"
"10","ACCOUNTING","NEW YORK"
"10","ACCOUNTING","NEW YORK"
Create One Receive Activity for ReadEmpDataFile and two Invoke Activity for two write operation adapters. Two Invoke Variables need to get values from Receive variables. To do this we will need one Assign Activity. (We will discuss about individual Processes in next articles). Final BPEL Process will look like
In Assign_1 activity we can assign individual data elements from Receive Activity XML to individual Emp and Dept XML variables
Rebuild the Project and Deploy it on local SOA Suite.
FTP Adapters
FTP Adapters work in the similar manner like File Adapter. While using FTP Adapter One needs to take care the FTP Adapters are setup on Application Server. Separate Adapter is needed for each machine to which FTP operation is used. Developer has to make sure that JNDI Name used in BPEL Project of JDeveloper exists on Oracle Application Server
FTP Adapters have Get File and Put File Operations and it supports both ASCII and Binary Files
Remaining steps of FTP Adapter are same as File Adapter.
File Paths used for Both FILE and FTP adapters can be physical path or logical path. We have used physical path in above example. Logically path can be specified as follows:
Summary:
File and FTP Adapter services are similar in the way they get used in JDeveloper BPEL/ESB designer. The only difference we can say if there must be one FTP Adapter setup for each machine to/from which files will be transferred. The JNDI Names used for FTP Adapters in BPEL Process designer must be present on Application Server.
Next article onwards, we will be discussing various Process Activities and other features branching/loouping etc related to BPEL.
Comments
If you go to /bpel/domains/d efault/tmp
and do ls -al you will see all the deployed bpel processes (extracted from the bpel jar).
In here you will find all the wsdl's and the bpel-file
I am trying to use FTP adapter with logical path trying to do archive the file. But it is not working for me. Can you please tell me how to do the same for logical path.
Is it any specific setup required on BPEL process? Please let me know the same.
Thanks.
Regards,
Dhava l Rathod
Thanks for the reply.
Eric - I found the files. Thanks for the help.
Your above articles are really useful for the learners and same way I have some requirement to transfer files from one location to another location.
Can you please provide me some steps like your previous article using File and FTP adapters.
Rega rds
Venkat
I have one XSD file coming from BPEL process , I want to read this XSD file and display it on UI using Oralce JSF.
Another page, that can write to this XSD File using the mean of Orcl JSF form.
Thax
T hanks
Arvind
very useful article, but one question:
is it possible to have the ftp adapter archive processed files on the ftp server.
I use ftp adapter to get files from ftp server, but when processed I want them archived on ftp server, in different location.
That would of course mean a put to the ftp server.
The article is very useful. I created BPEL process with one File Adapter to read data from file and one File Adapter to write data to other file.
The process has one Receive and one Invoke activities. As we are doing file operation we don need any iput variable. I am able to deploy process. But how to Test ? Test tab on UI (server) is disabled.
Than ks
Suman
RSS feed for comments to this post