Trying to get REST working

Hey hello

Total beginner here …

I tried to change the loan-request example and switched the user process to a rest process. I just want to see if the engine make the rest request.

However when I try to redeploy I get the following error

ENGINE-16004 Exception while closing command context: ENGINE-09005 Could not parse BPMN process. Errors: 
* One of the attributes 'class', 'delegateExpression', 'type', or 'expression' is mandatory on serviceTask. | loan-request.bpmn | line 12 | column 73
org.camunda.bpm.engine.ProcessEngineException: ENGINE-09005 Could not parse BPMN process. Errors: 
* One of the attributes 'class', 'delegateExpression', 'type', or 'expression' is mandatory on serviceTask. | loan-request.bpmn | line 12 | column 73
        at org.camunda.bpm.engine.impl.util.EngineUtilLogger.exceptionDuringParsing(EngineUtilLogger.java:58)
        at org.camunda.bpm.engine.impl.util.xml.Parse.throwExceptionForErrors(Parse.java:191)
        at org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse.execute(BpmnParse.java:305)
        [....]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

The process is simple as that:

<?xml version="1.0" encoding="UTF-8"?>
    <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
      <bpmn:process id="approve-loan" name="Validation d&#39;emprunt" isExecutable="true">
        <bpmn:startEvent id="StartEvent_1" name="Loan request received">
          <bpmn:outgoing>SequenceFlow_0wbi1t6</bpmn:outgoing>
        </bpmn:startEvent>
        <bpmn:sequenceFlow id="SequenceFlow_0wbi1t6" sourceRef="StartEvent_1" targetRef="ServiceTask_15ik8lg" />
        <bpmn:endEvent id="EndEvent_0a4s9no" name="Loan request approved">
          <bpmn:incoming>SequenceFlow_0gal2s2</bpmn:incoming>
        </bpmn:endEvent>
        <bpmn:sequenceFlow id="SequenceFlow_0gal2s2" sourceRef="ServiceTask_15ik8lg" targetRef="EndEvent_0a4s9no" />
        <bpmn:serviceTask id="ServiceTask_15ik8lg" name="Approuver emprunt">
          <bpmn:extensionElements>
            <camunda:connector>
              <camunda:inputOutput>
                <camunda:inputParameter name="url">http://192.168.1.240</camunda:inputParameter>
              </camunda:inputOutput>
              <camunda:connectorId>http-connector</camunda:connectorId>
            </camunda:connector>
          </bpmn:extensionElements>
          <bpmn:incoming>SequenceFlow_0wbi1t6</bpmn:incoming>
          <bpmn:outgoing>SequenceFlow_0gal2s2</bpmn:outgoing>
        </bpmn:serviceTask>
      </bpmn:process>
      <bpmndi:BPMNDiagram id="BPMNDiagram_1">
        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="approve-loan">
          <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
            <dc:Bounds x="233" y="267" width="36" height="36" />
            <bpmndi:BPMNLabel>
              <dc:Bounds x="206" y="303" width="90" height="20" />
            </bpmndi:BPMNLabel>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNEdge id="SequenceFlow_0wbi1t6_di" bpmnElement="SequenceFlow_0wbi1t6">
            <di:waypoint xsi:type="dc:Point" x="269" y="285" />
            <di:waypoint xsi:type="dc:Point" x="528" y="285" />
            <bpmndi:BPMNLabel>
              <dc:Bounds x="346" y="275" width="90" height="20" />
            </bpmndi:BPMNLabel>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNShape id="EndEvent_0a4s9no_di" bpmnElement="EndEvent_0a4s9no">
            <dc:Bounds x="796" y="267" width="36" height="36" />
            <bpmndi:BPMNLabel>
              <dc:Bounds x="769" y="303" width="90" height="20" />
            </bpmndi:BPMNLabel>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNEdge id="SequenceFlow_0gal2s2_di" bpmnElement="SequenceFlow_0gal2s2">
            <di:waypoint xsi:type="dc:Point" x="628" y="285" />
            <di:waypoint xsi:type="dc:Point" x="796" y="285" />
            <bpmndi:BPMNLabel>
              <dc:Bounds x="712.5" y="275" width="90" height="20" />
            </bpmndi:BPMNLabel>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNShape id="ServiceTask_15ik8lg_di" bpmnElement="ServiceTask_15ik8lg">
            <dc:Bounds x="528" y="245" width="100" height="80" />
          </bpmndi:BPMNShape>
        </bpmndi:BPMNPlane>
      </bpmndi:BPMNDiagram>
    </bpmn:definitions>

And finally versions seems ok:

  • 7.4.0 for the server
  • 0.6.0 for the modeler
  • Kepler for eclipse

Any pointers ?

Thanks

Eriam

Back …

Soooo I resolved my problem by adding manually in the XML process file the following:

<bpmn:serviceTask id="ServiceTask_15ik8lg" name="Approuver emprunt" camunda:type="external">

And I got it working … I also had to add the method and headers accordingly to the rest example.

So my question turns into how do I specify the camunda:type="external" from the modeler ?

Thanks

Eriam

Hi,

just to clarify do you want to use a Camunda connector to call a REST service. Or do you want to use external tasks which you have to poll by yourself? Your first post looks like you want to use a connector. Your fix in the second post changes the service task to an external task.

Cheers,
Sebastian

Hi,

by the way I’m able to deploy your BPMN XML from your initial post without parsing exception. How did you configure your engine? Did you use a distro from camunda.org or did you configure your own engine? If the later did you enable the connect process engine plugin?

Cheers,
Sebastian

Hey Sebastian

Yes I am actually trying to make a rest request to feed a rest service with information from the workflow. So as far as I understand I was actually trying to work with a connector.

I checked my conf/bpm-platform.xml and it missed the org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin .

Now that I added it I was able to remove the camunda:type="external" and it works as you said.

Now I changed the method to POST and I’m trying to get the workflow variables flowing to the rest service. Is that even possible ? (I can’t find any reference to it in the doc…).

Anyway congrats for the great piece of software.

Eriam

Hi Eriam,

for an example how to use variables for a POST request have a look at the SOAP example. It uses a freemarker template as payload. In the freemarker template you can access process variables by there name. Please make sure the freemarker template engine is installed in your environment.

Does this help you?

Cheers,
Sebastian

Hey

It helps a lot, thanks.

I got everything working smoothly but had to fallback to an inline script since I cannot manage getting the right url to refer the script to. Anyway since I’m just posting to a rest service an inline script is fine.

All the best !

Eriam

Hi,

you can read more about resources paths for scripts in the scripting section of the user guide. They either have to be part of the classpath or the deployment.

Cheers,
Sebastian

Hey thanks

Yes, I went through that topic but still couldn’t figure it out. I’ll try again later today after a fresh restart and a couple of coffees.

Regards

Eriam