How to use else-if activity in Oracle SOA

How to Use else-if ladder in Oracle SOA

Before going to the below use case, Please refer How to create Addition BPEL process and Subtraction BPEL process

Use Case:

We will be creating BPEL process which will call differenet mathematical services based on our request. For more clarification refer below flow chart.

D:\Data For Transfer\Screenshots\calculations with if\5.JPG

Step 1: Create a SOA Project in Jdeveloper.

D:\Data For Transfer\Screenshots\calculations with if\1.JPG

Fig: 001

D:\Data For Transfer\Screenshots\calculations with if\2.JPG

Fig: 002

D:\Data For Transfer\Screenshots\calculations with if\3.JPG

Fig: 003

D:\Data For Transfer\Screenshots\calculations with if\4.JPG

Fig: 004

Here in Fig: 03 we can see the three columns called as swim lanes

  • Exposed Services – Used for Inbound services from where we will get request which is also called Source System
  • External References – Used for Outbound services where we use to send request to external system which is also called target system
  • Components – Used to develop integrations also called as Workspace.

Step 2: Drag and Drop BEPL Process in to the Workspace

BEPL Process is used to implement internal functionality of the Web Service. This helps in receiving input from external web service, invoke a web service adapter, reply to the web service and performs many activities that are involved in implementing a web service.
In this project we are using Synchronous Web Service as it
sends a response back to Client after completing its operations.

D:\Data For Transfer\Screenshots\calculations with if\6.JPG

Fig: 006

D:\Data For Transfer\Screenshots\calculations with if\7.JPG

Fig: 007

Here we can see the check box Expose as a SOAP Service (checked by default). This creates a new SOAP web service in the Exposed services side (i.e., to the left of BPEL).
It also generates an XML Schema with input as “
process” and output as “processResponse

 

Step 3: Now edit the XML Schema file that has been generated under Schemas folder. Here we need to edit “BPELProcess1.xsd” which is under the Schemas folder.

D:\Data For Transfer\Screenshots\calculations with if\8.JPG

Fig: 008

D:\Data For Transfer\Screenshots\calculations with if\9.JPG

Fig: 009

The XML Schema defines the structure of request and response objects.

Here the “Process” element defines the Input/request object that will be sent as a request (XML file) to the web service, whereas the “processResponse” element defines the Output/response object that will be the response generated by the web service (XML file).

Here we need two integer values and a String value as input for our Conditional Calculation service which in return generates the sum (or) difference (or) product of the two integers (or) an error message (i.e., one output).

So we update the process element with two inputs of type integer, one as string type and processResponse element with one output variable of type string.

D:\Data For Transfer\Screenshots\calculations with if\10.JPG

Fig: 010

D:\Data For Transfer\Screenshots\calculations with if\11.JPG

Fig: 011

Step 4: Now Drag and Drop SOAP web service on to the external references lane

D:\Data For Transfer\Screenshots\calculations with if\12.JPG

Fig: 012

  • Rename the SOAP Reference as required (Here named as AdditionReference).
  • Copy Paste the wsdl file location in the WSDL URL tab (or) you can also browse the local wsdl file which we have discussed in previous subtraction project using no service. (wsdl files are shown in Fig: and Fig: )
  • Click on the port type which will be automatically selected depending on port type defined in the WSDL.

D:\Data For Transfer\Screenshots\calculations with if\13.JPG

Fig: 013

D:\Data For Transfer\Screenshots\calculations with if\14.JPG

Fig: 014

Similarly create web service references for subtraction and multiplication as shown below

  • For Subtraction

D:\Data For Transfer\Screenshots\calculations with if\15.JPG

Fig: 015

  • The above is the Substraction WSDL URL copied and pasted in WSDL URL as shown in Fig: 016.
  • This WSDL is generated after deploying the subtraction project on to the SOA server (that have been created and deployed earlier).

D:\Data For Transfer\Screenshots\calculations with if\16.JPG

Fig: 016

  • Renamed as Subtractionreference.
  • For Multiplication

D:\Data For Transfer\Screenshots\calculations with if\17.JPG

Fig: 017

D:\Data For Transfer\Screenshots\calculations with if\18.JPG

Fig: 018

After creating the three web services the project looks as shown in Fig: 019

D:\Data For Transfer\Screenshots\calculations with if\20.JPG

Fig: 019

Step 5: Now link the BPEL to Addition, Subtraction and Multiplication Service References as shown below,

D:\Data For Transfer\Screenshots\calculations with if\21.JPG

Fig: 020

D:\Data For Transfer\Screenshots\calculations with if\22.JPG

Fig: 021

Step 6: Double click on the BEPL process for implementing internal functionality. Here you can see the SOAP web service in partner link lane on source side linked with receive service (recieveInput) and reply service (replyOutput) in the workflow.

Fig: 022

D:\Data For Transfer\Screenshots\calculations with if\22-2.JPG

Fig: 023

Step 7:  Drag and drop if activity on to the workspace next to the Receive service as shown below.

D:\Data For Transfer\Screenshots\calculations with if\25.JPG

Fig: 024

  • If activity is much similar to the if-else condition in programming languages like C, C++, Java.
  • You can use if activity when conditional behavior is required for specific activities to decide between two or more branches.
  • Only one activity is selected for execution from a set of branches. 
  • Here we select only one service refernce among the three web service references with the help of ‘if activity’.

D:\Data For Transfer\Screenshots\calculations with if\26.JPG

Fig: 025

  • You can click on the green colored + symbol to add another else-if conditional branch as shown in the Fig: 026.
  • Here we added two else-if conditions other which makes four branches for the if-activity.
  • This activity invokes any of the addition, subtraction and multiplication services or an error note in case no condition is matched.

D:\Data For Transfer\Screenshots\calculations with if\27.JPGFig: 026

Step 8: Label the If conditional branches.

D:\Data For Transfer\Screenshots\calculations with if\28.JPG

Fig: 027

  • Name the conditions with its respective functionality by clicking on the “label”.
  • Here we have labelled the activities as Add, Sub, Multiply and Error for its respective functionality.
  • Fig: 029 shows the complete figure of if activity with its labels

D:\Data For Transfer\Screenshots\calculations with if\29.JPG

Fig: 028

D:\Data For Transfer\Screenshots\calculations with if\30.JPG

Fig: 029

Step 9: Provide condition for each branch in the If activity.

  • Double click on the branch node (Mouse pointer pointing to if in Fig: 029)
  • Click on the expression symbol on the pop-up raised as shown in Fig: 30.  
  • Another Pop-Up is raised where we need to place our condition.

D:\Data For Transfer\Screenshots\calculations with if\31.JPG

Fig: 030:

Expression

  • Expand the input variable payload under variables (XPath) part
  • Double click on the variable which is needed for condition
    (here we use the “operand” variable in which the user enter a character (+, -, *)).
  • To the left of Variables (Xpath) column we have Functions column in which we can choose required function.
  • Choose Logical Functions from the drop down menu and then choose equals function
  • You can insert variables and functions by double clicking on that or by using the “Insert into expression” button provided.
  • To use “Insert into expression” button first we need to select the Variable/Function and then click on that button to add it into the expression
  • You can check the syntax and functionality of a specific function in the description given (It shows only when we select a function).

D:\Data For Transfer\Screenshots\calculations with if\32.JPG

Fig: 031

D:\Data For Transfer\Screenshots\calculations with if\32-1.JPG

Fig: 032

  • Similarly we create conditions for both “sub” and “multiply” branches as shown I figures Fig: 032 and Fig: 033 respectively.

D:\Data For Transfer\Screenshots\calculations with if\33.JPG

Fig: 033

D:\Data For Transfer\Screenshots\calculations with if\33-1.JPG

Fig: 034

D:\Data For Transfer\Screenshots\calculations with if\34.JPG

Fig: 035

D:\Data For Transfer\Screenshots\calculations with if\35.JPG

Fig: 036

D:\Data For Transfer\Screenshots\calculations with if\35-1..JPG

Fig: 037

Step 10: Drag and Drop Invoke activity on to the work space next to the “Add conditional Branch” for invoking Addition web service as shown below.

  • This invoke activity needs to invokes Addition web service as that branch gets executed when user enters ‘+’ as operand.
  • Wire Invoke with Addition service reference as shown in Fig: 039
  • Rename Invoke.
  • Create local Input and output variables for Addition web service in Invoke as shown in Fig: 040 and Fig: 041.

D:\Data For Transfer\Screenshots\calculations with if\36.JPG

Fig: 038

D:\Data For Transfer\Screenshots\calculations with if\37.JPG

Fig: 039

D:\Data For Transfer\Screenshots\calculations with if\38.JPG

Fig: 040

D:\Data For Transfer\Screenshots\calculations with if\39.JPG

Fig: 041

D:\Data For Transfer\Screenshots\calculations with if\40.JPG

Fig: 042

D:\Data For Transfer\Screenshots\calculations with if\41.JPG

Fig: 043

Step 11: Drag and Drop Assign Activity in the work space next to the “Add” conditional branch and before “AddInvoke” as shown in Fig: 044

D:\Data For Transfer\Screenshots\calculations with if\42.JPG

Fig: 044

D:\Data For Transfer\Screenshots\calculations with if\42-1.JPG

Fig: 045

Step 12: Map the Receive input variables to “AddInvoke” input variables.

  • Double click on the Assign Activity
  • Expand Receive Input payload on the left side i.e., inbound as shown in Fig: 046.
  • Expand AddInvoke input payload on the right side i.e., outbound as shown in Fig: 046.
  • Map the ReceiveInput variables to the AddInvokeInput variables as shown in Fig: 047.
    Here we map two input variables in the receive payload with input variables of the Addition service payload.

D:\Data For Transfer\Screenshots\calculations with if\43.JPG

Fig: 046

D:\Data For Transfer\Screenshots\calculations with if\44.JPG

Fig: 047

Step 13: Drag and Drop Assign Activity next to AddInvoke in the Addition branch as shown in Fig: 049.

D:\Data For Transfer\Screenshots\calculations with if\45.JPG

Fig: 048

D:\Data For Transfer\Screenshots\calculations with if\45-1.JPG

Fig: 049

Step 14: Map the “AddInvoke” output variables to Reply output variables.

  • Double click on the Assign Activity
  • Expand AddInvoke Output payload on the left side i.e., inbound as shown in Fig: 050.
  • Expand Reply Output payload on the right side i.e., outbound as shown in Fig: 050.
  • Map the ReplyOutput variables to the AddInvokeOutput variables as shown in Fig: 051.
    Here we map two input variables in the receive payload with input variables of the Addition service payload.

D:\Data For Transfer\Screenshots\calculations with if\46.JPG

Fig: 050

D:\Data For Transfer\Screenshots\calculations with if\47.JPG

Fig: 051

Repeat Step 10 to Step 14 to invoke and Map the Input and output variables for both Subtraction and Multiplication web services.

After Implementing the same for both Subtraction and Multiplication services the project looks similar to Fig: 52.

D:\Data For Transfer\Screenshots\calculations with if\48.JPG

Fig: 052

Step 15: Drag and Drop Assign Activity in else branch as shown in Fig: 053.

D:\Data For Transfer\Screenshots\calculations with if\49.JPG

Fig: 053

D:\Data For Transfer\Screenshots\calculations with if\52.JPG

Fig: 054

Step 16: Hardcode the Reply Output with some String.

  • Expand Reply Output payload on the right side i.e., outbound as shown in Fig: 055.
  • Right click on the output variable and click on the Expression as shownin Fig: 055.
  • Write your message within the quotes (here ‘Enter any of the Following + or – or *’ is our String) as shown in Fig: 056.

D:\Data For Transfer\Screenshots\calculations with if\50.JPG 

Fig: 055

D:\Data For Transfer\Screenshots\calculations with if\51.JPG

Fig: 056

D:\Data For Transfer\Screenshots\calculations with if\52.JPG

Fig: 057

Step 17: The Project is now ready to deploy on to the SOA Server, You can deploy your project as shown below,

D:\Data For Transfer\Screenshots\calculations with if\53.JPG

Fig: 058

0 responses on "How to use else-if activity in Oracle SOA"

Leave a Reply

© 2017 SCM Teck. All rights reserved.
X