Workflow Extensions with WSO2 API Manager — Part 1

Tharika Madurapperuma
3 min readApr 21, 2019

--

WSO2 API Manager is a product which allows you to extend its functionality in many aspects which you will not even think of. One such aspect is providing the capability to add workflow extensions to certain tasks that would require third party intervention or approval. These tasks include,

  1. Application Creation
  2. Application Registration
  3. API Subscription
  4. User Signup and
  5. API State Change

We will look at how these extensions can be used to fulfill our different business needs with WSO2 API Manager. In this article we will be focusing on engaging an Application Creation Workflow Extension. You will find details on other types of extensions from my next articles.

Prerequisites

  1. WSO2 API Manager 2.6.0 which you can download from here.
  2. WSO2 Enterprise Integrator 6.4.0. Download it from here.

Application Creation Workflow

By configuring an Application Creation Workflow, you can control the creation of applications in API Store.

Why do you need to control application creation?

An Application in Store is a collection of subscribed APIs that can be invoked by an authorization key generated for the application. Hence for an organization, there can be a situation which demands human intervention when an Application is created by a developer. For example, you might need to

  • Let the administrator provide approval before an application is created.
  • Provide limitations in application creation if it is offered as a paid service.
  • Restrict certain users from creating applications in API Store.

Now let’s see how this can be achieved.

Note : We will be running both WSO2 API Manager and WSO2 Enterprise Integrator in the same machine for this demonstration.

Step 1 : Configuring the Business Process Server (Enterprise Integrator)

  • By default, WSO2 Enterprise Integrator 6.4.0 is configured with a port offset of 2. Hence you don’t need to change the offset in <EI_HOME>/wso2/business-process/conf/carbon.xml.
  • Open <EI_HOME>/wso2/business-process/conf/humantask.xml and <EI_HOME>/wso2/business-process/conf/b4p-coordination-config.xml. Then change the <TaskCoordinationEnabled> property in both the files to true.
  • Now copy ApplicationCallbackService.epr and ApplicationService.epr files in <APIM_HOME>/business-processes/epr/ folder to <EI_HOME>/wso2/business-process/conf/epr/ folder. You will need to create an epr folder if it does not exist in EI.
  • Next start the EI server with the following command from within <EI_HOME>/bin. This is where we start the business-process profile of the WSO2 Enterprise Integrator(EI).

./business-process.sh

  • Login to the Management Console of EI using the following URL and the credentials admin:admin.

https://<host>:<port>/carbon (ex: https://localhost:9445/carbon in our case)

  • Under Main -> Manage -> Processes, add BPEL. Upload the ApplicationApprovalWorkFlowProcess_1.0.0.zip file found in <APIM_HOME>/business-processes/application-creation/BPEL. Before executing this step, please note the changes bellow.

For WSO2 API Manager 2.6.0, when you are doing the above step, you should first do the following.

  1. Extract the above zip file.
  2. Open the deploy.xml file and edit the following.

- Change endpointReference=”./../../../../repository/conf/epr/ApplicationService.epr” to endpointReference=”./../../../../conf/epr/ApplicationService.epr”

- Similarly change endpointReference=”./../../../../repository/conf/epr/ApplicationCallbackService.epr” to endpointReference=”./../../../../conf/epr/ApplicationCallbackService.epr”

3. Re-zip the unzipped folder and upload as the BPEL.

This step should be performed until this issue is fixed. Otherwise there will be an error deploying the BPEL.

  • Then go to Main -> Manage -> Human Tasks -> Add. Upload the ApplicationsApprovalTask-1.0.0.zip file found in <APIM_HOME>/business-processes/application-creation/HumanTask.

Now we have completed configuring the WSO2 Enterprise Integrator which will act as the Business Process Server for the Application Creation Workflow task.

Step 2 : Configuring API Manager

  • In the file <API-M_HOME>/repository/deployment/server/jaggeryapps/admin/site/conf/site.json, configureworkFlowServerURL” to point to the EI server.
  • Engage the WS Workflow Executor in API Manager as follows.
  1. Login to the Management Console (https://localhost:9443/carbon)
  2. Go to Main -> Resources -> Browse.
  3. Then access /_system/governance/apimgt/applicationdata/workflow-extensions.xml
  4. Then disable(comment) the Simple Workflow Executor, and enable(uncomment) WS Workflow Executor in this file. Also in the same configuration specify the service endpoint to the EI server and the credentials required to access the service. (admin:admin by default)
  5. Save the configuration file.

Step 3 : Verify the functionality

  • Access the API Store in WSO2 API Manager (https://localhost:9443/store)
  • Create a new application.
  • Now you will be able to see that the Application status shows INACTIVE (Waiting for approval).
  • Until an administrator approves the creation of this new application, the application status will be INACTIVE.
  • In order to approve the application creation, login to the Admin portal of API Manager (https://localhost:9443/admin)
  • Under Application Creation Approval tasks, approve the application creation.
  • Now if you access the Store, the status of the new application has changed to APPROVED.

Congratulations! You have successfully engaged an Application Creation Workflow in WSO2 API Manager.

Cheers!

--

--