BPMN REST tasks allow you to invoke REST endpoints within your BPMN processes. You can achieve this by adding a REST Task and handling the REST invocation part in a process implementation. This tutorial simulates a scenario, in which you access a REST endpoint of a Health Care Service via a REST Task to retrieve information of a patient appointment, and approve it based on the date as an administrator.
Before you begin,
- Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the
- Download the product installer from here, and run the installer.
Let's call the installation location of your product the <EI_HOME> directory. This is located in a place specific to your OS as shown below:
OS Home directory Mac OS
Select and download the relevant WSO2 Integration Studio ZIP file depending on your operating system from here, and then extract the ZIP file.
Deploying the backend service
Download the MSF4J service from Git Hub and copy the JAR file to the
<EI_HOME>/wso2/msf4j/deployment/microservices directory. The back-end service is now deployed in the MSF4J profile of WSO2 EI.
Sending the request to the backend service
Follow the steps below to send the request to the backend service. This creates the appointment of the patient.
Start the MSF4J profile.
Send a request to the Backend service by entering the below details using a REST Client (e.g., Postman).
In the Payload, set the
appointment_dateto a date, which is minimum one day after today's date. For example, in the below payload, it is assumes that today's date is
2018-08-16is set as the
HTTP Method Request URL Payload POST http://localhost:9090/grandoaks/categories/surgery/reserve
"name": "John Doe",
"email": "[email protected]gmail.com"
"doctor": "thomas collins",
"hospital": "grand oak community hospital",
Creating the BPMN artifacts
Follow the steps below to create the BPMN artifacts including the REST Task,
- Create a new BPMN project named RestTaskBPMN. For instructions, see Creating a BPMN Project.
- Create a BPMN Diagram named RestTask.bpmn. For instructions, see Creating the BPMN Diagram.
- Click anywhere on the canvas, go to the Properties tab, and fill in the following details:
REST Task Process
To implement the order approval process, drag and drop a Start Event element, a REST Task element, a User Task element and an End Event element to the canvas.
You view the Create connection option when you hover the mouse pointer on an artifact. Click on the arrow, drag it and drop it on the artifact to which you want to connect it.
Configuring the Start Event
Select the Properties tab of the Start Event, click Form , click New , update the following and click OK.
|Name of the Patient||string||True||True||True|
You view both fields added to the form as shown below.
Configuring the REST Task
- Select the Properties tab of the REST Task, click General and enter the Name as Get Appointment.
In the Properties tab of the REST Task, click Main config and update the following:
HTTP method GET Output Variable Mappings
Be sure to use only one parameter (Output Variable Mappings parameter or the Output Variable Name parameter) to specify the variable mappings.More information on the properties of the REST Task
After adding the REST Task to your BPMN Diagram, you can configure the below Properties appropriately, as explained below.
Field Name String Value Required/Optional Service URL
URL of the target endpoint.
You can give this instead of the Service Reference (EPR).
BasicAuth Username Username if the endpoints are secured Required BasicAuth Password Password for the username above Required Service Reference (EPR)
Registry resource path of the endpoint reference.
You can give this instead of the Service URL.
HTTP Method HTTP method (GET. POST, PUT or DELETE) Required Input Payload Request payload Optional Output Variable name
Name of the variable to save the response.
Be sure to use only one parameter (Output Variable Mappings parameter or the Output Variable Name parameter) to specify the variable mappings.
Optional Output Variable Mappings
Variable mappings to map JSON response content into multiple variables.
Optional Transport headers
Header values in the format
Configuring the HTTP client
The above REST task is bundled with an HTTP client by default. You can edit its configurations in the
<EI_HOME>/wso2/business-process/conf/activiti.xmlfile as shown in the example below.
Configuring the User Task
- Select the Properties tab of the User Task, click General and enter the Name as Confirm Appointment.
- Click Properties , click Main config and give
adminas the Assignee.
In the Properties tab click Form , click New and add the following.
Id Name Type Readable Writable Required
Do You Approve the
Appointment Cancellation Request?
enum True False True
Click New next to Form values and add the following:
Id Name approve Approve reject Reject
In the Properties tab click Form, click New and add the following.
Id Name Type Variable Readable Writable Required
Number of Days long noOfDays True False True
You view the fields added to the Form of the User Task as shown below.
Press Ctrl+S to save all your artifacts.
Deploying the artifacts
- For instructions on creating the deployable artifacts, see Creating the deployable archive.
- For instructions on deploying them, see Deploying BPMN artifacts.
Testing the output
- Log in to the BPMN-explorer at https://localhost:9445/bpmn-explorer using
adminfor both the username and password.
- Click PROCESSES in the top menu, and click the Start option of the REST Task Process.
Enter a value for the Name of the Patient and Appointment Number and click Start. This creates a Claimable Task.
You need to enter the Appointment Number you received in the response of the service invocation above.
- Click TASKS in the top menu, and then click Claimable Tasks.
Click on the new Claimable Task .
You should not approve the appointment if the Number of days is less than one.
You view the Appointment Number you entered before and the Number of Days retrieved as 1, which means you can approve it since it is one day ahead from today.
- Click Complete Task, to approve the appointment.
- Click TASKS → COMPLETED TASKS to view the completed task.