WSO2 BPS supports invoking rest endpoints out of the box. Follow the following steps to add a RESTTask to your workflow using Activity BPMN 2.0 designer.
Give the json payload to the input field. This time use the expression box in add field dialog to give the json value instead of string value box. Add new field called "outputMappings" and mention the mapping format from response json, similar to "var2:customer.name,var3:item.price" format.
EDIT on 14/05/2016
Enjoy with REST!!
- Add the BPMN designer to your Eclipse installation using the update site here.
- Start a new BPMN project.
- Add a new service task from the tasks palette.
- Go to the task properties panel and open main config tab.
- Select "Java class" as task type.
- Give "org.wso2.carbon.bpmn.extensions.rest.RESTTask" as the Class name.
- Now add fields with following names, and values in String value field, under documentation section.
- serviceURL - rest service endpoint
- method - http method to use
- basicAuthUsername - username if the endpoints are secured
- basicAuthPassword - password for the username above
- input - payload to be sent
- outputVariable - process variable to save the response
- headers - header values in the format "key1:value1,key2:value2"
Now you can retrieve the response from the variable specified above in the succession steps of the workflow.
Refer the screenshot below to find out the important places you require inside eclipse designer.
Changing the endpoint after process deployment
The REST endpoint could not change after deploying the process in above method. If you want to change the endpoint after deploying the process also, pointing to a registry location which contains an endpoint reference as mentioned in Endpoint+References. For this add a field with name "serviceRef" instead of the "serviceURL" field and give the registry location of the service reference as the value.
Using json payloads
You can send json as the payload also.
EDIT on 14/05/2016
REST task sample
I have added a sample at BPMNRESTSample. This sample make a REST call to a mocky.io endpoint and display the response in a user task. Deploy the sample in WSO2 BPS and start a new process instance from BPMN Explorer shipped with BPS.
Enjoy with REST!!