Sunday, April 25, 2010

HOw to create an output file with same name as input file using file/ftp adapter in BPEL

Aim
=====
Our requirement is that we will be using two file adapter one for inbound and one for outbound.The name of output file generated should be same the name of the input file.


System Requirement
===================
Database oracle-10.2.0.3
SOA Suite 10.1.3.4
Jdeveloper 10.1.3.4


This is the environment i am using at my end.


Design
=======

OK The steps are as follows

1>Create a empty BPEL process.



2>Drag and drop a File adapter in the swimlane of your process.



Make it read only



Provide a location for polling the file




In the file name pattern give *.* as input



Make polling frequecy as 1 second.



Use native schema for processing.



3>Now drag and drop a receive activity and connect it to the File adapter you just have created.




4>Again drag and drop one more file adapter this time for outbound to write the file.




make it write



Give output directory and output file name



Again make it as native schema.

5>Now drag and drop a invoke activity after the receive activity in your bpel process and connect it to the fileout Partnerlink.




Ok So far most of the designing process is done but before going further in the design we need to analyse certain files in the jdeveloper.

Now if you will look at the folder for each adapter filein and fileOut you will get two files getting created for the adapter.

One is FileIn.wsdl which contains all the information that you have provided using GUI and Jdeveloper created one more file by its own it is called as FileAdapterInboundHeader.wsdl file ,If you will open this file you will get two header elements

<element name="fileName" type="string"/>
<element name="directory" type="string"/>

These contains the information about the file name and the directory from which it is coming.It is the header element for the inbound file.

Similarly we have FileAdapterOutboundHeader.wsdl which also contains the file name property.

So we will just map the input header variable for fileName to output header element so that the new file thus created will take the same name as input file.

For doing this we will create two header variable.Double click on receive activity and go to adapter tab.



6>create a variable and choose message type.



In the messag type select the inputheader wsdl file



Now our input header variable is created ,Now again double click on invoke activity
go to adapter tab and create one more header variable.

create one more variable outputheader and in the message type choose the output header wsdl



7>Now drag and drop an assign activity and assign the filename from input header to fileName in output header.



So after completion your project should look like this.




Now deploy your process and check if it works as expected.

I provided an inputfile name arpit.txt and in the output folder i got the file name as arpit.txt

No comments: