Unknown macro: {next_previous_links}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

BPMN REST tasks allow you to invoke rest endpoints within your BPMN processes. This can be achieved by adding a Service Task and handling the REST invocation part in a level implementation. BPS has provided this functionality out of the box to avoid the hassle of doing implementations by process developers.

Adding a REST task to a process

To add a REST task, you need to add a Java task in place of the process where you need to do the invocation.

Pre-requisite

This guide demonstrates adding a REST task using the Eclipse BPMN Designer. Use the update site, to add this plugin to your eclipse. You can do the same in any other editor by adding the same property values.

  1. Add a “Service task” from the tools palette in the place where you need to invoke the endpoint. 
  2. Go to the properties panel of Service Task and open the main config tab. 
  3. Select Java Task as the Task Type 
  4. Add the following fields with names, under the Documentation section by clicking the New button.

    Field NameString ValueExpression
    serviceURL  <REST ENDPOINT URL>
    methodHTTP method (GET or POST only) 
    outputVariableName of the variable to save response 
    basicAuthUsernameUsername if the endpoints are secured 
    basicAuthPasswordPassword for the username above 
    inputRequest payload 
    headersheader values in the format "headerName1:headerValue1,headerName2:header Value2" 

The following code block provides an example service task definition to use as the REST task.

<serviceTask id="servicetask1" name="REST task1" activiti:class="org.wso2.carbon.bpmn.extensions.rest.RESTTask">
    <extensionElements>
        <activiti:field name="serviceURL">
            <activiti:expression>http://10.0.3.1:9773/restSample1_1.0.0/services/rest_sample1/${m ethod}
            </activiti:expression>
        </activiti:field>
        <activiti:field name="basicAuthUsername">
            <activiti:expression>bobcat</activiti:expression>
        </activiti:field>
        <activiti:field name="basicAuthPassword">
            <activiti:expression>bobcat</activiti:expression>
        </activiti:field>
        <activiti:field name="method">
            <activiti:string>
                <![CDATA[POST]]>
            </activiti:string>
        </activiti:field>
        <activiti:field name="input">
            <activiti:expression>Input for task1</activiti:expression>
        </activiti:field>
        <activiti:field name="outputVariable">
            <activiti:string>
                <![CDATA[v1]]>
            </activiti:string>
        </activiti:field>
        <activiti:field name="headers">
            <activiti:string>
                <![CDATA[key1:value1,key2:value2]]>
            </activiti:string>
        </activiti:field>
    </extensionElements>
</serviceTask>
  • No labels