[jBPM7 QuickTips] Service Tasks

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.

Service Tasks Administration Page

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. 

Lognew 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 NameRequiredVariable Description Default
UrlAlwaysURL from the service which to be called. Example: http://serviceUrl:port/service/1
MethodAlwaysHTTP Method to be used. Values accepted examples: POST, PUT, DELETE, GETGET
ContentDataIf the method is POST or PUTRequest body to send to the service
ContentTypeIf the method is POST or PUTHTTP Header which contains the format of the body being sent. Example of values: application/json, application/x-www-form-urlencoded. 
ConnectTimeoutNoConnection timeout limit for the request, in seconds60

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 NameVariable Description 
ResultThe response body will be stored in this process variable. 
ResultClassThe class in which the engine should convert the result to. The return by default is a String. Example: If setting the value to “”, the engine will try to convert the string stored in Result, to this class type.
StatusHTTP Response status. IE: 200, 404, 500. 
StatusMsgUsually 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:


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:


The FORM_BASED auth requires an additional authURL parameter. The configuration looks like:

Restnew“username”, “password”, “”,classLoader)

Additionally, it is possible to override these configurations in each REST Task using the following parameters:

Variable NameRequiredVariable Description 
usernamewhen using auth and not set on deployment descriptorUsername to authenticate on the rest service.
passwordwhen using auth and not set on deployment descriptorThe password to authenticate on the rest service.
authUrlWhen using FORM_BASED authRefers to the j-security-check URL of the authentication service. 

3 thoughts on “[jBPM7 QuickTips] Service Tasks

  1. 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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s