Echoing a Message Using Correlation
This tutorial guides you on how to create a BPEL process to assign a value in the request to the response and echo it using the WSO2 Enterprise Integrator (WSO2 EI) Tooling. It walks you through the steps to demonstrate how you can assign the input string of the request message to the result string of the response message using BPEL Correlation.
Also, if you are facing any problems with this Tutorial, you can import the pre-packaged project of this Tutorial to WSO2 EI Tooling, and compare your configurations with the ones in it.
Before you begin,
- Download the product installer from here, and run the installer.
Let's call the installation location of your product the<EI_HOME>
directory.Note that if you used the product installer to install your product, the
<EI_HOME>
is located in a place specific to your OS as shown below:OS Home directory Mac OS /Library/WSO2/EnterpriseIntegrator/6.3.0
Windows C:\Program Files\WSO2\EnterpriseIntegrator\6.3.0\
Ubuntu /usr/lib/wso2/EnterpriseIntegrator/6.3.0
CentOS /usr/lib64/EnterpriseIntegrator/6.3.0
Select and download the relevant WSO2 EI tooling ZIP file based on your operating system from here and then extract the ZIP file.
The path to this folder is referred to as<EI_TOOLING>
throughout this tutorial.Getting an error message? See the troubleshooting tips given under Installing Enterprise Integrator Tooling.
Creating the BPEL Workflow
Create a new BPEL Workflow using the below details.
- Project Name:
EchoCorrelationProcess
- Process Name:
EchoCorrelationProcess
- Template:
Synchronous BPEL Process
For instructions, see Creating a BPEL Workflow.
Creating the artifacts
Follow the steps below to create the required artifacts.
- Right click on the FIX_ME-Add_Business_Logic_Here element, and click Delete to remove it from the default diagram.
Drag and drop an Assign activity to the canvas and place it after the receiveInput activity.
Drag and drop this from the Actions section of the Palette.
- Drag and drop an Receive activity to the canvas and place it after the replyOutput activity.
Drag and drop another Assign activity to the canvas and place it after the Receive activity.
Drag and drop a Reply activity to the canvas and place it after the Assign1 activity.
You view the artifacts you added as shown below.
Creating the variable
Follow the steps below to create a variable to temporary store the values passed from the request message.
- In WSO2 EI Tooling under the EchoCorrelationProcess menu, click the + sign on the Variables panel, to add a new variable and name it tempVar.
- Click on the tempVar variable, and click Browse in the Details section of its Properties tab.
- Select From Imports under Show XSD Types, select the below Filters, select the string XML Schema under the Matches and click OK.
- Click OK in the message, which pops up.
Configuring the Partner Link
In this scenario, you are using the client Partner Link, which is available by default. Follow the steps to set the Service Role of it.
- In the EchoCorrelationProcess menu, click on the client Partner Link.
- Click Details in its Properties section and double click process under My Operations.
Configuring the receiveInput activity
Click on the receiveInput activity and in the Details section of the Properties tab, select
client
as the Partner Link.- Select Process as the Operation.
- In the Quick Pick: box, expand the process → EchoAsyncProjectRequestMessage → payload : EchoAsyncProjectRequest drop down and double click on the process option.
Configuring the Assign activity
- Click on the Assign activity, click Details in the Properties tab, and click New.
- Click New and in the From: box, expand the input : EchoCorrelationProcessRequestMessage drop down and select the input : string option.
- In the To: box, select tempVar : string.
- Press Ctrl+S to save the variable mapping.
- Click New and in the From: box, expand the input : EchoCorrelationProcessRequestMessage drop down and select the input : string option.
- In the To: box, expand the output : EchoCorrelationProcessResponseMessage drop down and select the result : string option.
- Press Ctrl+S to save the variable mapping.
- Click Yes in the message, which pops up to initialize the variables.
- Click New and in the From: box, select Expression and enter concat('Instance created with correlationID: ', $tempVar) as the expression.
- In the To: box, expand the output : EchoCorrelationProcessResponseMessage drop down and select the result : string option.
- Press Ctrl+S to save the variable mapping.
Configuring the replyOutput activity
- Click on the replyOutput activity and in the Details section of the Properties tab, select
client
as the Partner Link.
- Keep your cursor on the Operation field and double-click on process.
- Double click process in the Quick Pick section to generate the input and output variables for this element.
Configuring the Receive activity
- Click on the Receive activity and in the Details section of the Properties tab, select
client
as the Partner Link .
- Keep your cursor on the Operation field and double-click on process.
- Double click process in the Quick Pick section to generate the input and output variables for this element.
Configuring the Assign1 activity
- Click on the Assign1 activity, click Details in the Properties tab, and click New.
- Click New, and in the From: box, select input : EchoCorrelationProcessRequestMessage → payload : EchoCorrelationProcessRequest → input : string.
- In the To: box, select tempVar : string.
- Press Ctrl+S to save the variable mapping.
- Click New and in the From: box, expand the input : EchoCorrelationProcessRequestMessage drop down and select the input : string option.
- In the To: box, expand the output : EchoCorrelationProcessResponseMessage drop down and select the result : string option.
- Press Ctrl+S to save the variable mapping.
- Click Yes in the message, which pops up to initialize the variables.
- Click New and in the From: box select Expression and enter concat('Correlated response: ', $tempVar).
- In the To: box, select result : string.
- Press Ctrl+S to save the variable mapping.
Configuring the Reply activity
- Click on the Reply activity and in the Details section of the Properties tab, select
client
as the Partner Link. - Keep your cursor on the Operation field and double-click on process.
- Double click process in the Quick Pick section to generate the input and output variables for this element.
Creating the Correlation Set
Follow the instructions below to add a correlation to this process.
- Click on the receiveInput element.
- In WSO2 EI Tooling under the BankLoanProcess menu, click the + sign on the Correlation Sets panel, to add a new correlation.
- Select the Correlation Set you created, and click Add in the Details section of its Properties tab.
- Click New in the Select a Property window.
- Enter id as the Name and click Browse.
- Select From Imports under Show XSD Types, select Simple Types and Complex Types under Filter, select the ns1 : string under the Matches and click OK.
- Click OK in the message, which pops up the set the prefix of the namespace.
Creating the first Alias of the Correlation Set
Click the New located next to the Aliases label in the Create Message Property window.
This maps the Correlation property you created to the matching property of the receiveInput request. This is to act as the alias for correlation.
- Select Message Type and click Browse.
Select From Imports under Show XSD Types, select Messages under Filter.
Select EchoCorrelationProcessRequestMessage under Matches, select input : string under Type Structure and click OK.
Click OK in all the subsequent windows.
Mapping the Correlation to the request
- Click on the receiveInput element and click Add in the Correlation section of its Properties tab.
- Select Yes under the Initiation column for the correlation you added.
- Click on the Receive element and click Add in the Correlation section of its Properties tab.
- Select No under the Initiation column for the correlation you added.
Setting the ports of the Partner Links for deployment
- Double click on the
deploy.xml
file in the Package Explorer.
Select the EchoCorrelationProcessPort for the client Partner Link.
Deploying the artifacts
- For instructions on creating the deployable artifacts, see Creating the deployable archive.
For instructions on deploying them, see Deploying the BPEL Workflow.
Testing the output
- In the Management Console of the Business Process profile, click Main → Manage → Processes → List → BPEL, and click on the Process ID of the Bank Loan BPEL process you uploaded.
In the WSDL details section, select client as the Partner Link and click Try It.
You can now invoke it with input values.
- In the Request section of the Try It tool, replace the question mark with the Helloworld text.
- Click Send. You view the response in the Response section.
- Click Send again. You view the second response in the Response section.