Friday, 14 October 2011

ESB BPEL Using Oracle SOA Suite -Article III 10g file and ftp adaptors

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.
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"
For WriteDeptFile use Department CSV file in following format
"DEPTNO","DNAME","LOC"
"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.

No comments:

Post a Comment