While loop in SOA

In this post let’s see how we can use While loop in SOA BPEL.

In the example below, we pass input as a number (n) and the response would be sum of all numbers till n (0+1+…n).

  • Create SOA Application (SOA_Appln)
  • Create SOA Project (SOAproj_While)
  • Create BPEL (Synchronous BPEL 2.0)
  • Edit the XSD like below.


  • Create two scope variables at BPEL scope level (‘sum’, ‘i’) of type ‘xml schema simple type – int’.

  • Now add Assign activity below receive activity and double click on it. drag an expression and give the value 0 and map it to the scope variable ‘sum’ which we created before. similarly create another expression, give value as 0 and map it to scope variable ‘i’.

  • Now drag the while activity below the Assign1 activity.¬† Double click on it and give the condition as ($i < $inputVariable.payload/client:input) which means while this condition satisfies the loop will be executed.

  • Now we need to increment the value right, so drag the assign activity inside while loop and double click on it.¬† drag the expression builder and give the value as $i+1 and map it to scope variable ‘i’. similarly again drag expression builder and give value as $i+$sum and map it to scope variable ‘$sum’ which means we are summing the sum value with the current loop count. (If loop is 4 then sum would be sum+4. Till the loop3, sum will be 1+2+3 =>6. So at loop4 sum would be sum+4 => 6+4 => 10.

  • We are done with the while loop. After the loop exits, now we need to assign the final sum value which we stored in the scope variable ‘sum’ to the output variable. So create an assign activity after while loop and double click on it.

  • The final BPEL will look like below.

  • Deploy the application to SOA server.
  • Let’s test the project. Give input as ‘4’ and the output would be ’10’.

Happy Looping ūüôā



Translate Native Format File to XML File and Vice versa using Translator in SOA 12c

Translator is the new component introduced in SOA 12c which is very useful to convert any native format file like CSV to XML and vice versa.

Now am going to create a new application and BPEL process for doing this in JDeveloper 12.1.3

1) Create a new SOA Application named ‘TranslateApplication‘ and a project named ‘TranslateProj


2) Select Composite with BPEL Process and click on Finish

3) Name the BPEL Process as ‘TranslateBPELProcess‘ and Template as ‘Synchronous BPEL Process’ and click on OK


4) Drag and drop the Translate Activity which is under Oracle Extensions to the BPEL Process and double click on it.


5) Click on the Search icon and for Input and assign the client:input variable to it


6) For NXSD Schema field Click on the ‘New xsd icon’ and Select file type as Delimited¬†and click on Next.


7) In the next screen browse the File and click on Next.


8) Select File contains only one record and Next. In next screen Enter the name for element as ‘Emp’


9) Check the Use First Record as the Field Name and click on Next and Finish.


10) Create an Output variable for assigning to reply Output and click on OK.


11) Now open the created Schema and remove the few xsd:schema attributes which are not required (nxsd:hasHeader, nxsd:HeaderLines , nxsd:headerLinesTerminatedBy) and save it.


12) Deploy the Project to server


13) ¬†Give the value for input as ‘Ravi, 15, 1000’ and click on Test Web Service and then click on ‘Launch Flow Trace’


14) Click on Input and Translate to see the comma seperated input and XML output.


15) If you are not able to see the Translate value in XML format then click on the deployed project and under settings change the Composite Audit Level to Development and test again. You can see the response in XML Format.


BPEL Creation with DB Adapter usage and consuming it in ADF application as webservice

Story of Project:  We are going to pass the employee id from the ADF web application to SOA BPEL, which fetches more details of an employee from the database and returns them to ADF which are then shown on the ADF page. Tool used for this project is JDev 12.1.3

This Post includes the following

  • SOA Application¬†creation
  • DB Adapter Configuration (for connecting to Database)
  • BPEL Creation (WSDL generation)
  • ADF Application Creation
  • Consuming the WSDL and create data controls
  • Test from the ADF Application

SOA Application Cretion:

Create a SOA Application with name ‘SOA_fetchDBdataApp’


Create a Project ‘FetchEmpDataProj’ and select the Composite With BPEL Process¬†while project creation


Create a BPEL with the name ‘fetchEmpDetailsBPEL’ and select Template as Synchronous BPEL Process and then click OK


The BPEL will be created with receiveInput and replyOutput as default schema components.


Navigate to Databases tab and create a new Database Connection with the name with which we created in console


Now Navigate the Database Adapter to the bpel flow

Note: Before proceeding from this step you should configure your DB Adapter in the console first. Please go through the DB Adapter configuration steps given at the end of the post.


Give the dbreference name and click on Next


Click on Search Icon and select the created Database Connection and click on Copy Connection


Check only Select check box as we are doing only select operation in this example and click on Next


Click on Query button to select the existing table in DB and move it to the selected area by clicking on right single row.


Now remove the unneccessary  relationships by selecting each and clicking on remove button


Click on Add button for creating a bind variable to the query which basically used to pass a variable dynamically. Generally to apply where condition its been used


Click on Edit button beside to query click on Add button and then Check the Parameter option and select the created parameter ’empId’ from dropdown


You can observer the modified SQL query


Click on Next and finally Click on Finish


Drag and drop the Invoke BPEL Constructor below to input and map to the dbreference


Configure the Input and Output for this DB adapter. Click on + symbol and give names to the input and output variables.


Now drag and drop the Assign Constructor below to input


Double click on Assign which opens a Edit Assign popup in which map the input variable value to input of database adapter and click on Apply and OK


Now assign the output of DB Adapter to the reply output of BPEL.  For that use Assign constructor.  Here the output of DB adapter has many fields so create as many outputs in the schema also to map from DB Output to BPEL output.

Open the schema file (.xsd file) and add the the required inputs and outputs in its source view


Now drag and drop the Assign Constructor to below to DB adapter to  map the output of DB Adapter to BPEL output.


And then double click on it for mapping. a popup window opens where map the output of DB adapter to output variable of BPEL. Map all fields directly. There is field named ‘EmpName’ at¬†the output section for which the input should be from two fields (firstname, lastname) so drag and drop the Expression icon to the output field ‘EmpName’


On Drag of Expression onto field a popup opens where click on concat and then click on first name and last name. The format should be concat(val1, val2) which combines the output of these two fields  and stores in EmpName field.


Finally click on Apply and OK



Save the project and right click on project-> Deploy


Click on Deploy to Application Server.

Check the box Overwrite any existing composites with the same revision ID. which basically useful for generating same wsdl url for every deployment. Click on Next


Click on Integrated weblogic server. Here you can add any server and deploy to that.

Select the domain (Default Server) and click on Finish which finishes the deployment.


Open Enterprise Manager on browser. Select the project and click on Test


Copy the WSDL to clipboard. Give the input as 102 and click on Test Web Service


It opens the Response tab with the result. you can Launch Flow Trace to view the complete step by step response


ADF Application Creation:

Create ADF Fusion Web Application ‘ADF_SOA_App’ keep the default names for the project.


Create a custom project ‘consumeEmpWS’


Right click on the created project -> New -> Select Web Service Client and Proxy


Paste the copied WSDL URL in the WSDL Document URL field and click on Next and proceed by keeping default settings and Finish.

Right click on the WSDL and click on Test Web Service which opens a Http Analyzer.


Give the input and click on Send Request which returns Response at right side.


Now right click on the WSDL file and click on Generate Data Controls which generates the data controls which can be used on in the ADF page.


You can see the updated data Controls Section


Now Create a jspx page under View Controller Project.


Check the JSP XML and name it ‘getDetails.jspx’


Go to Source code of the page and then drag and drop the web service data controls on to the center facet of the page and select the option as ADF Parameter Form.


Now right click on the page and click on Run


In the page pass the Employee Id and you can see the more details which are fetched through BPEL and displayed on the page.


DB Adapter Configuration:

This includes creation of Data Source, DB Adapter Outbound Connection Creation, mapping created Outbound Connection Creation with created data source.

Open Console and Create Data Source for connecting to the database.


Create a New Generic Data Source


Give the connection name as ‘HRConn’ and JNDI name as ‘jdbc/HRConnDS’ for the data source


Give the Database Connection details and click on Next


Click on Test Configuration which shows a success message for the successful connection. Click on Finish.


Click on DbAdapter from the deployments


Click on Configuration -> Outbound Connection pools -> New and then create an outbound connection


Click on Next


Give the JNDI name for the Outbound connection as eis/DB/HRConn


Click on the Created Outbound Connection Pool


Give¬†the property ¬†value for XA Data Source name as with earlier created¬†DataSource jndi name ‘jdbc/HRConnDS’ and click on save


Now again go to deployments and select DbAdapter and click on update which ends the DB Adapter Configuration.