Friday, August 8, 2008

File Adapter : Hidden Treasure-2

Getting File Size

I am assuming that people reading this blog know how to get the File name and the input directory of the file. In this blog entry I will demonstrate an another aspect of File Adapter i.e. getting the input file size.
Note:- If you don't know about getting file name & input directory, refer to my blog entry dated 14th June 2008.

Introduction:
If you see the fileAdapterInboundHeader.wsdl file in Jdeveloper, you will notice that this wsdl is containing only two elements i.e. fileName and directory. Now If you goto the BPEL Console and look closely at the variable part (which contains file name and directory information), you will notice that at runtime Assign activity is displaying 5 elements. So I felt that somehow I can get the file size too. Its pretty simple.

Solution:
To acheive it, just you have to modify the fileAdapterInboundHeader.wsdl file. Note that the fileAdapterInboundHeader.wsdl is a read-only file so to modify it, you have to remove the read-only permission. After removing the permission you can edit the code.

After change, the code will look like this:


Note the highlighted element "size" below the directory element. After doing the changes, apply the read-only permission back to the file(not necessary).

Now you will be able use the size attribute in your assign activity.

Pretty cool stuff...right..

Have a Happy Happy learning...

No comments: