Monday, May 13, 2013

Passing Dynamic values to JCA Adapters for Files in SOA 11G

Hi All,

Sometimes,there are requirements like this when you have to pass values such as file names or file directory at runtime while working with File adapters.For all the outbound operations such as write,sync Read and list files you can dynamically pass filenames and directories to your JCA adapter during invocation of a BPEL process.

To illustrate the above usecase,Ill be modifying my existing code which I developed for explaining DVMs in my last post.

Step1: Drag and drop a file adapter onto the external references lane.
Step2: File adapter wizard will open up.Configure the file adapter for write operation and specifiy output directory and file name to be written.Please note these values are dummy values since,they will be modified at runtime when call to file adapter will be made.
Step3: Same schema used for DVM tutorial will be used here for defining the messages for the write file operation.Click finish.

Step4: Call to File adapter is made using invoke activity and input variable for file adapter is created using "+" sign.To see how to create variables for invoke activities kindly refer my previous posts.
Step5: Now drag and drop assign activity for populating the input payload for file adapter.Fields such as FName,LName,City,Designation in the input payload is mapped to the input variable for invoking file adapter.Create two new variables of string data type namely "NewFileName" and "NewDir".Now we will set the values for these two variables in the same assign activityiin which we mapped the inpt file variable.These are the values that will be passed at runtime to file adapter for write operation.

Step6: Now, we will set the new filename and new filedirectory.Double click the invoke activity and switch to "Properties" tab.Drill down to properties "jca.file.filename" and set its values to variable that we created "NewFileName".
Step7: In the same manner for "jca.file.Directory" set its values to "NewDir".
Step8: In this manner we pass the values to any JCA adapter during runtime.
Step9: Save all compile and deploy hte code to EM.
Step10: Test the newly created SOA service.Pass the values and invoke Test Web Service.
Step11: Open up the flow trace of the invoked instance and notice the value for filename and filedir being passed at runtime.
Step12: Now got to the location whose dir path was given in file adapter at runtime.File is written with a name we gave at runtime.
Step13: Open the file to verify the contents of the file.

Step14: Likewise,you guys can pass dynamic values to other JCA adapters as well.List of available properties for every adapter can be seen under properties tab of an invoke activity.Hope you guys enjoyed and learned the concept of passing dynamic values at runtime.

Happy Learning,

1 comment:

  1. Thanks for the wonderful post....keep writing....:)