Working with REST Tasks
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.

Working with REST Tasks

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 simluates 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.

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.

  1. Start the MSF4J profile. For instructions, see Staring the product profiles.

  2. Send a request to the Backend service by entering the below details using a REST Client (e.g., Postman).

Creating the BPMN artifacts

Follow the steps below to create the BPMN artifacts including the REST Task,

  1. Create a new BPMN project named RestTaskBPMN. For instructions, see Creating a BPMN Project.

  2. Create a BPMN Diagram named RestTask.bpmn. For instructions, see Creating the BPMN Diagram.

  3. Click anywhere on the canvas, go to the Properties tab, and fill in the following details:
    Id               : restTask
    Name         : REST Task Process
    Namespacehttp://wso2.org/bpmn/restTask

  4. 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. 

Configuring the Start Event

Select the Properties tab of the Start Event, click Form, click New, update the following and click OK.

Id

Name

Type

Required

Readable

Writable

Id

Name

Type

Required

Readable

Writable

patientName

Name of the Patient

string

True

True

True

appointmentNo

Appointment Number

long

True

True

True

 

You view both fields added to the form as shown below.

 

Configuring the REST Task

  1. Select the Properties tab of the REST Task, click General and enter the Name as Get Appointment

  2. In the Properties tab of the REST Task, click Main config and update the following: 

Configuring the User Task

  1. Select the Properties tab of the User Task, click General and enter the Name as Confirm Appointment

  2. Click Properties, click Main config  and give admin as the Assignee. 

  3. In the Properties tab click Form, click New and add the following.

    Click New next to Form values and add the following:

  4. In the Properties tab click Form, click New and add the following.

    You view the fields added to the Form of the User Task as shown below.

  5. Press Ctril+S to save all your artifacts.

Deploying the artifacts

  1. For instructions on creating the deployable artifacts, see Creating the deployable archive.

  2. For instructions on deploying them, see Deploying BPMN artifacts.

Testing the output

  1. Log in to the BPMN-explorer at https://localhost:9445/bpmn-explorer using admin for both the username and password.

  2. Click PROCESSES in the top menu, and click the Start option of the REST Task Process.

  3. Enter a value for the Name of the Patient and Appointment Number and click Start. This creates a Claimable Task.

  4. Click TASKS in the top menu, and then click Claimable Tasks

  5. Click on the new Claimable Task.


    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.

  6. Click Complete Task, to approve the appointment.

  7. Click TASKS → COMPLETED TASKS to view the completed task.

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.