In my previous example I have explained about the polling operation of file adapter. Now I am going to give you an example of a�?Synchronous Read Filea�� operation of file adapter in BPEL process. Synchronous read means polling will depend on the input variables. This is on demand polling service. In this example file directory and file name will be the variables and data will be inserted into database from file. Follow the below steps to complete this example.
- Create a SOA Project. Right click on application -> New -> Project. Select SOA project and Enter name a�?SyncReadFilea��
- Select composite type as a�?Composite with BPELa��
- Click on a�?Finisha�� and a�?BPEL processa�� wizard will open. Enter BPEL process name and select BPEL template type as a�?Synchronous BPEL Processa��
- Click on a�?OKa�� and BPEL composite will open.
- Drag a File Adapter from Component (BPEL Services -> File) and drop it in the right swim lane of the BPEL process.
- a�?File Adapter Configurationa�� wizard will open. Enter reference name
- Configure file adapter as mentioned in the previous example. Only change the operation type of file adapter as a�?Synchronous Read Filea��
- Check the previous example and proceed further with the configuration of the file adapter.
- Now create two variables (file directory and file name) in BPEL Process.A�Click on a�?Variablesa�� icon in the main scope.
- Click on green plus sign
- Enter variable name and select type of the variable (string type).
- Now variable window will look like this
- Drag and drop a�?Assigna�� activity between receiveInput and replyOutput
- Now assign value to both the variables. Right click on fileDir and select Expression
- Write expressions for both variables as mentioned in the below screenshot. Expression can be created in the a�?Expression Buildera�� also. Select substring from String Functions and select a�?Insert Into Expressiona��. Then insert input payload and then last-index-within-string from String Functions.
- Now a�?Editor assigna�� window will be like this.
- Drag and drop a�?Invokea�� activity after Assign activity and connect the wire between Invoke activity and ‘InputFile’ partner link (File adapter).
- a�?Invoke Editora�� window will open. Enter proper name of the Invoke activity and create input and output variable by clicking the green plus sign.
- Click on OK and Invoke window will look like this.
- Go to the property tab in the Invoke window and assign the variables to the value of the properties as shown in the below screenshot.
- Click on a�?OKa�� and BPEL will be like this
- Drag and drop database adapter in the right swim lane. Go to BPEL Services -> Database
- a�?Database Adapter configurationa�� wizard will open. Refer my previous article a�?Select operation on Database Adaptera�� for the configuration of Database Adapter. Select database connection, JNDI connection and operation type as a�?Insert Onlya�?.
- Drag and drop an a�?Invokea�? activity after the first Invoke activity which is connected to the file adapter
- Enter name of the Invoke activity and create input and output variables.
- If Database Adapter partner link moves to the left swim lane then move it to the right swim lane. Right click on DB partner link and select Display -> Move to Opposite Swim Lane
- Drag and drop a a�?Transformationa�? activity in between two Invoke activities.
- Double click on Transformation activity and select a�?Sourcea�? and a�?Targeta�? variable
- Source will be the output from the invoke activity of the file adapter and Target will be the input of the invoke activity of Database adapter.
- Click on a�?OKa�� and transformation file will open. Do the mapping between source and target items.
- Now set a confirmation message to the output variable of the BPEL process
- Drag and drop an a�?Assigna�� activity after the second Invoke activity and set a message to the output payload in the assign activity.
- BPEL Process will beA�like this.
- Deploy the project in the server and test the project in the Enterprise Manager Console.
- Keep the file in the location that is mentioned in the below screenshot and that will be the input to the application.
- Click on a�?Test Web Servicea�� and output message will display
- Check the table in database
- All the data in the file has populated in the table.
Issue ofA�Invoke activityA�of this SOA application:
Here I am going to share my issue while creating this project. I have faced one issue at the time of a�?Invokea�� activity. Output tab was disabled like the below screenshot.
Solution:
Here is the solution detail approach with steps below:
1.Add a property in xml format in .jca file of database adapter.
2.Add output message in the WSDL.