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.
...
Tip | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before you begin,
|
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
...
Start the MSF4J profile.
Panel borderColor #542989 bgColor #ffffff borderWidth 1 Localtabgroup Localtab title On MacOS/Linux/CentOS Open a terminal and execute the following command:
Code Block wso2ei-6.4.0-msf4j
Localtab title On Windows Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.4.0 MSF4J. This will open a terminal and start the MSF4J profile.
Send a request to the Backend service by entering the below details using a REST Client (e.g., Postman).
Tip In the Payload, set the
appointment_date
to a date, which is minimum one day after today's date. For example, in the below payload, it is assumes that today's date is2018-08-14
so that2018-08-16
is set as theappointment_date
.HTTP Method Request URL Payload POST http://localhost:9090/grandoaks/categories/surgery/reserve {
"patient": {
"name": "John Doe",
"dob": "1940-03-19",
"ssn": "234-23-525",
"address": "California",
"phone": "8770586755",
"email": "johndoe@gmail.com"
},
"doctor": "thomas collins",
"hospital": "grand oak community hospital",
"appointment_date": "2018-08-16"
}
Anchor request request
...
- Log in to the BPMN-explorer at https://localhost:9445/bpmn-explorer using
admin
for 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.
Tip 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 .
Tip 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.