WIH Configuration Tips
Service Task Configuration Tips: Service tasks need additional configuration, set in the Deployment Configuration, Work Item Handlers Section of the project. These configurations can either be set manually or added via the Service Tasks menu.
Manual configuration of Work Item Handlers of Service Tasks (used for advanced configuration):

Default Service Tasks default installation (asks for basic configuration):

All configuration done via Business Central is inserted into /projectDir/src/main/resources/META-INF/kie-deployment-descriptor.xml.
There is also available in business central, a list of WIH to be used. Access business central settings, in the top right settings icon and select “Service Tasks Administration.”
The following page will be displayed with lots of options for service tasks like integration with Twitter, Camel, Docker Daemon, FTP, Github, Calendars, Jabber, Slack, Vimeo and several other.

Additionally, in this page you can upload and enable custom tasks (work item handlers) jars 🙂
Service Tasks – Additional Details
Log Task
To configure the Log task to be used in the project, add it to the Work Item Handler section of the project settings.
Name | Value |
Log | new org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler() |
Rest Task Configuration
Let’s go through the possible input variables used in the REST task. Some of the possible Input variables are:
Variable Name | Required | Variable Description | Default |
Url | Always | URL from the service which to be called. Example: http://serviceUrl:port/service/1 | |
Method | Always | HTTP Method to be used. Values accepted examples: POST, PUT, DELETE, GET | GET |
ContentData | If the method is POST or PUT | Request body to send to the service | – |
ContentType | If the method is POST or PUT | HTTP Header which contains the format of the body being sent. Example of values: application/json, application/x-www-form-urlencoded. | – |
ConnectTimeout | No | Connection timeout limit for the request, in seconds | 60 |
It is common to use dynamic values in the URL. They can be used with the notation ${variableName} . I.e.
http://serviceUrl:port/service/${myVariable} .
The output variables used to capture the result from the request above could be:
Variable Name | Variable Description |
Result | The response body will be stored in this process variable. |
ResultClass | The class in which the engine should convert the result to. The return by default is a String. Example: If setting the value to “com.my.organization.Person”, the engine will try to convert the string stored in Result, to this class type. |
Status | HTTP Response status. IE: 200, 404, 500. |
StatusMsg | Usually contains a String message when the response is not successful. |
Finally, to use this service task, initialize it in the project deployments configuration as presented previously in this post.
The following name and WIH Class can be used in the project configuration:
Name | Value |
Rest | new org.jbpm.process.workitem.rest.RESTWorkItemHandler() |
The configuration above is used to do requests for a service which does not require any authentication mechanism. When authentication is required, the following approaches can be used:
- The authentication parameters can be informed in the WIH initialization;
- The authentication parameters can be set on each Rest Task inside the process. This will override the initialization options;
Let’s check both approaches. To set the auth parameters during the initialization, it’s necessary to pass them into the constructor. And two auth options can be used: FORM_BASED or BASIC. The BASIC auth, requires only username and password:
Name | Value |
Rest | new org.jbpm.process.workitem.rest.RESTWorkItemHandler(“username”,”password”) |
The FORM_BASED auth requires an additional authURL parameter. The configuration looks like:
Name | Value |
Rest | new org.jbpm.process.workitem.rest.RESTWorkItemHandler(“username”, “password”, “http://authservice.com/j-security-check-url”,classLoader) |
Additionally, it is possible to override these configurations in each REST Task using the following parameters:
Variable Name | Required | Variable Description |
username | when using auth and not set on deployment descriptor | Username to authenticate on the rest service. |
password | when using auth and not set on deployment descriptor | The password to authenticate on the rest service. |
authUrl | When using FORM_BASED auth | Refers to the j-security-check URL of the authentication service. |
hi, thanks for posting this post, it helped me so much to learn about the Rest Task. I just have a question and I hope that you can help. Actually I get a json response from my REST API , it works fine for me and I can print the response into a String variable. But, I want to cast this response into an Object. I created a “Data Object” having as attributes the same names in my json response. and in my REST TASK, I put the type of Result as the “Data Object”, the same for ResultClass as you descpried , but the engine can not convert the String value into my class type. I hope that my question is clear.
LikeLike