Tuesday, October 26, 2010

How to dynamically pass the file name and file path in file adapter "write" 10G and 11G

Hello,

Lets see how to pass the directory location for the outgoing file in file adapter, for this we will proceed as follows.

Step 1. We will drop a new file adapter and configure it to use logical path, once we select logical path we need to configure the out directoy inside the bpel.xml file, the catch is we are setting the values of the property by using java embedding inside the BPEL process.

Step 2. This is how our bpel.xml file looks now.




We now use a java activity to dynimically set the path of the logical path inside the bpel.xml file

//dynamically set the property value inside bpel.xml file
try {
//get the location from the varible inside BPEL process
String location=(String)getVariableData("Variable_location");
// Update the bpel.xml file with value
// DemoFileWrite is name of bpel process, FileWrite is the name of the file adapter
getLocator().lookupProcess ("DemoFileWrite").getDescriptor().getPartnerLinkBindings()
.getPartnerLinkBinding ("FileWrite").setPropertyValue ("file_out",location);
}
catch(Throwable ex) {
//Log.logError("w_bpltph_errXMLCatchDetails","Failed file location creeeation",Log.ERROR_SEVERITY_FATAL,"","",fault_string);
}

If you are using SOA 11G this is very easy to do.
Just go inside the property tab when you double click on the Invoke activity, inside the property of Invoke there are different properties which you can set. Just click on the Values text space in front of the property it will take you to Adapter Property screen where you can browse the value for this property.





Thursday, June 3, 2010

Reading a XML file using File adapter in Oracle BPEL

Read XML file using Oracle BPEL file adapter.

Hi, This is my first blog and I am very excited about it.

From some last few months I am working on File adapter and wondering how complex is a file adapter. Also I feel the design of file adapter is very strange, because the behavior of file adapter is very different from what we ever expect.

Here is a simple example of reading a XML file using file adapter. With file adapter we can either read or write a file,

The read operation can be either a "synchronous read" or "read",

In Synchronous read, inside an a BPEL process we can provide the file details and read a file,

In a ‘read operation’ we can poll a file from a directory.


Now we will see how we can read a file (poll) in windows environment
Sample files
Emp.xml


Note** for UNIX environment change target namespace
xsi:schemaLocation="http://www.example.org \home\file\XSD\emp.xsd"

Emp.xsd



Step1. Create a new empty BPEL project


Step2. Drop a file adapter from 'component pallet --> services' to ‘Services’ inside Jdeveloper window



Step3. Configure file adapter

(a) Name the file adapter which will becomes the service name.



(b) Select ‘read’ as operation type.

(c) Provide directory location for incoming file, here we can browse the location or can give the logical path name and can later configure it inside the bpel.xml file.

(d) File filtering, this is wild pattern for a file name.

(e) Configure polling frequency and the age of file i.e. the time the file has been inside the directory.

(f) Provide the schema file (XSD), this is a very interesting configuration screen, as we can decide here weather we want to read a XML file, opaque file or CSV file, etc



(g) Finish

Step4. Configure the receive activity to receive the contents from file adapter, remember selecting the create instance.



Step5. Finish



Step6. Deploy



Step7. Test







Some interesting facts about file adapters
1.) If the XML file is incorrect then by default the file will get deleted and will move to “Oracle_Home\bpel\domains\domain_name\jca\project_directory\rejectedMessages”, however we can move it to location of our desire by configuring “failedMessageHandlers” property inside bpel.xml
2.) The file adapter does not verify the contents of the XML file with the schema mentioned in the file adapter (Step 3, f); what it does by default is verify the contents of the XML with the schema mentioned inside the XML file’s target namespace.