How To Read From A File in Mid-Process
Oracle(R) BPEL Process Manager - Version: 10.1.2
Goal
How to read from a file in the middle of a process?
Solution
The proper way to read from a file in the middle of a BPEL process is to use the built-in XPath function, ora:readfile. Avoid using the file adapter to read a file. The file adapter (Read) is not designed for reading a file in the middle of a process. It is used to trigger the BPEL process in most cases. So in this scenario, the file adapter is not a good choice. Also it needs to use correlation sets to read files in the middle of a process.
Embedded Java code can solve the problem, but it is hard to maintain, and also not recommended.
How to use the ora:readfile function:
1. Drag an Assign activity and place it in the correct position in the BPEL process
2. Create a new Assign rule using the ora:readfile("file path", "xml schema path") XPath function
3. Assign the result to a variable.
A Code Example:
<assign name="Assign_1">
<copy>
<from expression="ora:readFile("file:///D:\\tmp\\PO.xml",
"file:///D:\\tmp\\OrderBookingPO.xsd")"/>
<to variable="var1" query="/ns1:PurchaseOrder"/>
</copy></assign>
Goal
How to read from a file in the middle of a process?
Solution
The proper way to read from a file in the middle of a BPEL process is to use the built-in XPath function, ora:readfile. Avoid using the file adapter to read a file. The file adapter (Read) is not designed for reading a file in the middle of a process. It is used to trigger the BPEL process in most cases. So in this scenario, the file adapter is not a good choice. Also it needs to use correlation sets to read files in the middle of a process.
Embedded Java code can solve the problem, but it is hard to maintain, and also not recommended.
How to use the ora:readfile function:
1. Drag an Assign activity and place it in the correct position in the BPEL process
2. Create a new Assign rule using the ora:readfile("file path", "xml schema path") XPath function
3. Assign the result to a variable.
A Code Example:
<assign name="Assign_1">
<copy>
<from expression="ora:readFile("file:///D:\\tmp\\PO.xml",
"file:///D:\\tmp\\OrderBookingPO.xsd")"/>
<to variable="var1" query="/ns1:PurchaseOrder"/>
</copy></assign>
Comments
I have a problem in ora:readFile. It's reading only first record and not all rows. Any tweak for this to achieve?
Rgds,
Nikhil