Introduction:
File Adapter is integrated with SOA suite 12C to make the way easy to handle all the file based transaction. You can do operations on files in pretty easy way like reading files, write on files, synchronous read file. However, processing of files can be done on demand basis or polling basis.
In this example, we will see polling operation of file adapter and the data in the file will be inserted into database table.
Implementation of SOA application:
- First step is to create a SOA project. Right click on application -> New -> Project. Select SOA project and Enter project name a�?FileAdapterPollingPrja��
- Click on a�?Nexta�� and select composite type as a�?Composite With Mediatora��
- Click on a�?Finisha�� and a�?Create Mediatora�� wizard will open.
- The composite will look like this.
- Now drag a�?File Adaptera�� in the a�?Exposed Servicesa�� swim lane and a�?File Adapter Servicea�� window will open.
- Enter service name and click on a�?Nexta��
- Select Adapter Interface a�?Define from operation and schemaa�� and click on a�?Nexta��.
- Select JNDI name of file Server to access the file server at runtime.
- Select Operation type as a�?Read Filea��
- Give physical path of the incoming file and select other options as shown in the below screenshot.
- Enter the pattern of the file name and click on a�?Nexta��. SOA application will select only those files from directory whose name starts with a�?empa��.
- Click on a�?Nexta�� and Change the polling frequency as per the requirement.
- Schema element is required for file operation. Click on a�?Nexta�� and then select the cog icon beside the URL field.
- Enter the file name of the schema and click on a�?Nexta��.
- Select file type
- Browse the sample file for creating schema
- Select the option ‘File contains multiple records’ and ‘Multiple records are of single type’
- Click on a�?Nexta�� and accept the default options. Finally the below window will come with the XSD.
- Click on a�?Nexta�� and will navigate back to the schema definition window
- Now the composite will look like this.
- Drag DB Adapter in the a�?External Referencesa�� swim line and Database Adapter Configuration wizard will open.
- Give Database connection details and JNDI connection details.
- Select operation type as a�?Insert Onlya�� for Database Adapter.
- Click on a�?Nexta�� and select the table from schema.
- Select primary key column in the selected table.
- Now select the columns where data will be inserted from file.
- Click on a�?Nexta�� and select any sequence (depends on requirement) against the primary key column.
- Click on a�?Nexta�� and select the default options
- Click on a�?Finisha�� and now the composite will look like below screenshot
- Double click on mediator and click on the icon A�in the transformation option. This will help to create XSLT mapping between the input file and database table.
- Enter XSLT file name
- Click on a�?OKa�� and mapping file will open. Drag and drop a�?for-eacha�� operation in the target lane and do the mapping between source and target.
- Polling operation is done. Now deploy the project in the server. For deployment you can refer my HelloWorld Mediator service.
- Keep one file in the input directory and see in a fraction of a second file will be polled by the SOA application and data will be inserted in the table. Check the table in database.