cancel
Showing results for 
Search instead for 
Did you mean: 

Restservices in delegate class

ozkan
Champ in-the-making
Champ in-the-making
Hi,
I'll design a process that has a service-task and I want to service-task call a web or rest service . For this I will create a java delegate class and in this class I'll use the web or rest service . In activiti can we do this ? Is there a class that make this job ? Thanks for helping
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Hi,

For calling a REST service you can just implement a service task class that makes the call like you would from any Java class. For a web service you can choose to use the BPMN way or do it in a service task as well.

ozkan
Champ in-the-making
Champ in-the-making
Success,I made a simple process and delegate,
Here is my process;

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="helloworld-process" name="My simple process"
  isExecutable="true">
  <startEvent id="startevent1" name="Start"></startEvent>
  <serviceTask id="servicetask1" name="Hello World Service Task"
   activiti:class="com.example.HelloWorldServiceDelegate"></serviceTask>
  <sequenceFlow id="flow1" sourceRef="startevent1"
   targetRef="servicetask1"></sequenceFlow>
  <endEvent id="endevent1" name="End"></endEvent>
  <sequenceFlow id="flow2" sourceRef="servicetask1"
   targetRef="endevent1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_helloworld-process">
  <bpmndi:BPMNPlane bpmnElement="helloworld-process"
   id="BPMNPlane_helloworld-process">
   <bpmndi:BPMNShape bpmnElement="startevent1"
    id="BPMNShape_startevent1">
    <omgdc:Bounds height="35.0" width="35.0" x="110.0" y="130.0"></omgdc:Bounds>
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape bpmnElement="servicetask1"
    id="BPMNShape_servicetask1">
    <omgdc:Bounds height="55.0" width="105.0" x="210.0" y="120.0"></omgdc:Bounds>
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
    <omgdc:Bounds height="35.0" width="35.0" x="357.0" y="130.0"></omgdc:Bounds>
   </bpmndi:BPMNShape>
   <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
    <omgdi:waypoint x="145.0" y="147.0"></omgdi:waypoint>
    <omgdi:waypoint x="210.0" y="147.0"></omgdi:waypoint>
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
    <omgdi:waypoint x="315.0" y="147.0"></omgdi:waypoint>
    <omgdi:waypoint x="357.0" y="147.0"></omgdi:waypoint>
   </bpmndi:BPMNEdge>
  </bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

and here is my delegate class ;


package com.example;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;

public class HelloWorldServiceDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
  System.out.println("hello world");
}

}

Thanks for answer .

ozkan
Champ in-the-making
Champ in-the-making
Now  I'll try call a service in delegate class