Appendix B. Service Tasks
Service task is a task that uses a service, such as a mail service, web service, or another service.
For the convenience of the user, Red Hat JBoss BPM Suite comes with predefined types of service tasks:
- Web Service task for invoking a web service from a BPMN2 process.
- Email task for sending emails through the setup mail server.
-
Log task that calls the
SystemOutWorkItemHandlerclass. - REST task for sending REST calls.
Note that since the tasks extend the service task, their attributes are implemented as Assignments, DataInputSet, and DataOutputSet, not as separate properties.
In Process Designer, you can find these service tasks in the expanded Object Library on the left.
- In Business Central, go to Authoring → Project Authoring.
- In Project Explorer, locate the project and the respective process under BUSINESS PROCESSES.
- Open the process in Process Designer and expand the Object Library.
Drag and drop the selected service task to the required position on the canvas.

For more information about service task attributes, see Section B.1, “WS Task Attributes”, Section B.2, “Email Task Attributes”, and Section B.3, “REST Task Attributes”.
If you require other task types, implement your task as instructed in Section 4.15, “Domain-Specific Tasks”.
B.1. WS Task Attributes
The Web Service task implements the WebServiceWorkItemHandler class. The Web Service task serves as a web service client with the web service response stored as String. To invoke a Web Service task from a BPMN process, the correct task type must be used.
B.1.1. Use Cases
B.1.1.1. Multiple Parameters
The Web Service task can be used to invoke a web service method with multiple parameters. To do so, the following changes must be made to the BPMN2 process definitions:
-
In the Process Designer, open the Properties panel and select the Variable Definitions property to create a process variable called
pVarwith the typeObject[]. -
Select the WS task in the Process Designer and modify the WS Data I/O table by editing Assignments in the Properties panel, or by clicking the Edit Data I/O icon. Change WS Data Input from
Parameter:StringtoParameter:Object[]. -
Change the Data Inputs and Assignments section to map
pVartoParameter. Define an array of WS parameters by selecting the WS task in the Process Designer and adding the following to the On Entry Actions in the Properties panel:
Object[] params = {"firstParam", "secondParam"}; kcontext.setVariable("pVar",params);
This will allow the web service to be invoked with two parameters.
B.1.1.2. Custom Objects
In addition to primitive object types, the WebService task can use more complex objects, such as Person or Employee.
To use custom objects, the following steps are required:
- Create Custom Model objects using either the Data Modeler in Business Central or using an external tool, like Red Hat JBoss Developer Studio.
- Use this Custom Model class in one of the WebService tasks.
- Generate WSDL for this web service.
- Use Red Hat JBoss Developer Studio to generate Java classes from the WSDL.
-
Create a
.jarfile that includes the model class generated from the WSDL file. Addkmodule.xmlunder theMETA-INFof the.jar. -
Upload the
.jarto the Artifact Repository. In Business Central, add it to the list of project’s dependencies that includes the configured Web Service task. This Web Service task must have new classes generated, and cannot rely on the original ones. Modify the project configuration using the Deployment descriptor as follows:
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <kbase name="defaultKieBase" default="true" eventProcessingMode="stream" equalsBehavior="identity" packages="*"> <ksession name="defaultKieSession" type="stateful" default="true" clockType="realtime"> <workItemHandlers> <workItemHandler type="new org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler(ksession, runtimeManager.getEnvironment().getClassLoader())" name="WebService"/> </workItemHandlers> </ksession> </kbase> </kmodule>The above configuration utilizes the
WebServiceWorkItemHandler.
B.1.1.3. Web Service Task Example
This example demonstrates a process that obtains a weather forecast for given ZIP codes. The process looks as follows:

- In the first human task, the process asks for ZIP codes.
- Next, the result of the first human task is transformed into a collection that is used as an input for the service task with multiple instances.
- Based on the input collection, the process creates several service task instances for querying the weather forecast service.
- Once all the service task instances are completed, the result is logged to the console.
- Another human task then shows the weather forecast for the chosen ZIP codes.
After the process instance is started, the user is prompted to select the mode of the service task: synchronous or asynchronous. Note that the difference between the two can be noticeable depending on the particular service.
Input Attributes
- Endpoint
- The endpoint location of the web service you want to invoke.
- Parameter
- The object or array to be sent for the operation.
- Mode
-
Can be
SYNC,ASYNC, orONEWAY. - Interface
-
The name of a service, for example
Weather. - Namespace
-
The namespace of the web service, such as
http://ws.cdyne.com/WeatherWS/. - URL
- The web service URL, such as http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL.
- Operation
- The method name to call.
Output Attributes
- Result
- An object with the result.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.