How to trigger Webservice through flowable modeler


#1

Hi , can some body help me, how to create a process through modeler which triggers the webservice ?


#2

Hi.

You can use a Http Task for executing a call to a REST service. It’s located in the Activities section on the palette.

Regards,

Yvo


#3

Any example through modeler is there ? Please share


#4

A small xml that gets a JSON, parses it and creates an array so it can be used in a dropdownbox.
If you create a process in modeler and export it to xml you should be able to insert this example into it.

<serviceTask id="GetProducts" name="GetProducts" flowable:type="http">
  <extensionElements>
    <flowable:field name="requestMethod">
      <flowable:string><![CDATA[GET]]></flowable:string>
    </flowable:field>
    <flowable:field name="requestUrl">
      <flowable:string><![CDATA[http://url/rmt-web/node/children/24321?token=cBaqMmeGjm]]></flowable:string>
    </flowable:field>
    <flowable:field name="saveRequestVariables">
      <flowable:string><![CDATA[true]]></flowable:string>
    </flowable:field>
    <flowable:field name="resultVariablePrefix">
      <flowable:string><![CDATA[products]]></flowable:string>
    </flowable:field>
    <flowable:executionListener event="end" class="org.flowable.engine.impl.bpmn.listener.ScriptExecutionListener">
      <flowable:field name="script">
        <flowable:string><![CDATA[//get response
                        print("");
                        print("start getProducts");
						responseBody = execution.getVariable("productsResponseBody");
						print("Products: " + responseBody);
						jsonObject = JSON.parse(responseBody);
 		  					    
 		  				//convert string into products array          				              				
          				var rmtNodes = new Array();			
						for (i = 0; i < jsonObject.length; i++) {
							rmtNodes[i]=new RmtNode(jsonObject[i].id,jsonObject[i].name);   
						}

						//prepare productsarray for dropdownbox 
						var jsonString = JSON.stringify(rmtNodes);
          				print("products dropdownbox: " + jsonString);
          				
          				//set variable for dropdownbox
          				print();
          				print();
          				execution.setVariable("cboProductValues",jsonString);
          				execution.setVariable("rmtUrl","24321");
          				
          				print(execution.getVariable("cboProductValues"));
          							
          				function RmtNode(id, name) {
          				    this.id = id;
           				    this.name = name;
          				}

          				print("getProducts done"); 
          				print("");]]></flowable:string>
      </flowable:field>
      <flowable:field name="language">
        <flowable:string><![CDATA[javascript]]></flowable:string>
      </flowable:field>
    </flowable:executionListener>
  </extensionElements>
</serviceTask>

#5

Hi,
jUnit tests in the flowable source

Regards
Martin