With the introduction of workflows, when users try to create an Application in the API Manager Store, their request will go into an intermediary state where in which it will remain till authorized by the workflow authorization administrator.
To enable the Application Creation workflow you will need to change the ApplicationCreation up executor from "ApplicationCreationSimpleWorkflowExecutor" to "ApplicationCreationWSWorkflowExecutor" in the <AM_HOME>/repository/conf/api-manager.xml (see below).
<!--ApplicationCreation executor="org.wso2.carbon.apimgt.impl.workflow.ApplicationCreationSimpleWorkflowExecutor"/--> <ApplicationCreation executor="org.wso2.carbon.apimgt.impl.workflow.ApplicationCreationWsWorkflowExecutor"> <Property name="serviceEndpoint">https://localhost:6666/services/ApplicationCreationWorkflow</Property> <Property name="username">admin</Property> <Property name="password">admin</Property> <Property name="callBackURL">https://localhost:8243/services/WorkflowCallbackService</Property> </ApplicationCreation>
When making this change you need to specify the service endpoint at which the Workflow Engine is hosted along with the credentials required to access said service via Basic Authentication (i.e. username and password).
Invoking the Workflow Engine
Once the ApplicationCreationWSWorkflowExecutor is engaged, whenever a user tries to create an application in API Manager Store, a request of the following format will be sent to the Worklfow Endpoint (You may refer the wsdl here when implementing your custom Worklfow Service) specified under "serviceEndpoint" in the API Manager.xml.
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wor="http://workflow.subscription.apimgt.carbon.wso2.org"> <soapenv:Header /> <soapenv:Body> <wor:createApplication xmlns:wor="http://workflow.application.apimgt.carbon.wso2.org"> <wor:applicationName>application1</wor:applicationName> <wor:applicationTier>Gold</wor:applicationTier> <wor:applicationCallbackUrl>http://webapp/url</wor:applicationCallbackUrl> <wor:applicationDescription>Application 1</wor:applicationDescription> <wor:tenantDomain>wso2.com</wor:tenantDomain> <wor:userName>user1</wor:userName> <wor:workflowExternalRef>c0aad878-278c-4439-8d7e-712ee71d3f1c</wor:workflowExternalRef> <wor:callBackURL>https://localhost:8243/services/WorkflowCallbackService</wor:callBackURL> </wor:createApplication> </soapenv:Body> </soapenv:Envelope>
A detailed explanation of each property is as follows.
Property | Description |
---|---|
applicationName | Name of the application the user wishes to create |
applicationTier | Throttling tier for the applcation |
applicationCallbackUrl | When the OAuth2 "Authorization Code" grant type is in action, this is the endpoint on which the callback needs to happen after the User is authenticated. (This is an attribute of the actual application registered on the store) |
applicationDescription | Description of the application |
tenantDomain | The tenant domain associated with the application (domain of the user creating the application) |
userName | username of the user creating the application |
workflowExternalRef | The unique reference against which a workflow will be tracked. This will need to be sent back from the Workflow Engine to API Manager at the time of workflow completion. |
callBackURL | At the time of workflow completion, this is URL to which the "Workflow completed" request will be sent to by the Workflow Engine. This property is configured under the "callBackURL" property in the api-manager.xml (Can be either a SOAP or REST endpoint) |
In addition to invoking the Workflow Engine, at the time of executing a Workflow an entry will be added to the AM_WORKFLOWS table in the API Manager Database, indicating the workflow status and workflow external reference along with a host of other information. This entry in turn will be used to track the progress of the workflow throughout its lifecycle. At a given time, the status of a workflow can be either 'CREATED', APPROVED' or 'REJECTED'. 'CREATED' is the default status of a workflow, it will get promoted to either 'APPROVED' or 'REJECTED' state based on the response from Worklfow Engine.