cancel
Showing results for 
Search instead for 
Did you mean: 

Invoking web services

alex1
Champ in-the-making
Champ in-the-making
Hie , i'm newer about activiti but i'm think that's so interesting.
I'have seen about invoke ws in a step of activiti workflow configuration, I'don't find it.
Is it possibile to do and including parameters too ?
thanks.
10 REPLIES 10

gant
Champ in-the-making
Champ in-the-making
Hi,

Maybe this acticle can help you: http://www.bpm-guide.de/2010/12/09/how-to-call-a-webservice-from-bpmn/

Regards
michael

dankre
Champ in-the-making
Champ in-the-making
Hi,

I try to call a webservice the standard way like its discribed in the article. But I have some problems with the target and source references. In the article Bernd Rücker use a ioSpecification element at the process element. Is this some kind of a hack to define the needed references?

Is there some other way to define these references, if my process has no inputs and outputs?

Regards
Daniel

  <serviceTask name="Call A" startQuantity="1" implementation="##WebService" operationRef="tns:requestA">
   <ioSpecification>
    <dataInput itemSubjectRef="tns:RequestAItem" id="dataInputOfServiceTask" />
    <dataOutput itemSubjectRef="tns:ResponseAItem" id="dataOutputOfServiceTask" />
    <inputSet>
     <dataInputRefs>dataInputOfServiceTask</dataInputRefs>
    </inputSet>
    <outputSet>
     <dataOutputRefs>dataOutputOfServiceTask</dataOutputRefs>
    </outputSet>
   </ioSpecification>
   <dataInputAssociation>
    <sourceRef>???</sourceRef>
    <targetRef>dataInputOfServiceTask</targetRef>
    <assignment>
     <from>${someProcessProperty}</from>
     <to>${dataInputOfServiceTask.value}</to>
    </assignment>
   </dataInputAssociation>
   <dataOutputAssociation>
    <targetRef>???</targetRef>
    <transformation>${dataOutputOfServiceTask.response}</transformation>
   </dataOutputAssociation>
  </serviceTask>

jbarrez
Star Contributor
Star Contributor
No, the ioSpecification is the BPMN 2.0 defined way to call a webservice

See http://activiti.org/userguide/index.html#bpmnWebserviceTask

dankre
Champ in-the-making
Champ in-the-making
Yes, it is all BPMN 2.0 standard.


  <process id="asyncWebServiceInvocationWithDataFlowUEL">
   <!–
    The Data Inputs and Outputs of a Process have to be explicitly
    declared with their type to be valid BPMN 2.0
   –>
   <ioSpecification>
    <dataInput id="dataInputOfProcess" itemSubjectRef="tns:setToRequestItem" />
    <inputSet>
     <dataInputRefs>dataInputOfProcess</dataInputRefs>
    </inputSet>
        <outputSet />
   </ioSpecification>
    …
    <serviceTask id="webService"
                 name="Call WS"
                 implementation="##WebService"
                 operationRef="tns:setToOperation">
            <!– The BPMN 2.0 Meta Model requires an Input/Output Specification –>
            <ioSpecification>
                <dataInput itemSubjectRef="tns:setToRequestItem" id="dataInputOfServiceTask" />
                <inputSet>
                    <dataInputRefs>dataInputOfServiceTask</dataInputRefs>
                </inputSet>
                <outputSet />
            </ioSpecification>
            <dataInputAssociation>
                <sourceRef>dataInputOfProcess</sourceRef>
                <targetRef>dataInputOfServiceTask</targetRef>
       <assignment>
        <from>${dataInputOfProcess.newCounterValue}</from>
        <to>${dataInputOfServiceTask.value}</to>
       </assignment>
            </dataInputAssociation>
    </serviceTask>
    …
  </process>

The ioSpecification inside the process element defines that the process has inputs and outputs. But what if my process has no inputs and outputs? What if these references are defined in my process? Normaly I need dataobjects but these elements are not documented in the userguide. Are dataobjects nevertheless supported by activiti?

An webservice example with complexe objects would be very helpful.

dankre
Champ in-the-making
Champ in-the-making
Yeah! It works!


<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="org.activiti.enginge.impl.webservice" xmlns:tns="org.activiti.enginge.impl.webservice"
xmlns:counter="http://webservice.activiti.org/">

<import importType="http://schemas.xmlsoap.org/wsdl/" location="http://localhost:63081/counter?wsdl"
  namespace="http://webservice.activiti.org/" />

<process id="webServiceInvocationWithParametersFromTask">
  <dataObject id="dataInputOfProcess" name="Input for webservice" itemSubjectRef="tns:setToRequestItem"/>

  <startEvent id="theStart" />

  <sequenceFlow id="flow1" sourceRef="theStart" targetRef="theScriptTask" />

  <scriptTask id="theScriptTask" scriptFormat="groovy" name="Execute script">
   <script>
       def scriptVar = "10"
       execution.setVariable("dataInputOfProcess", scriptVar)
     </script>
  </scriptTask>

  <sequenceFlow id="flow1a" sourceRef="theScriptTask" targetRef="webService" />

  <serviceTask id="webService" name="Call WS"
   implementation="##WebService" operationRef="tns:setToOperation">
   <!– The BPMN 2.0 Meta Model requires an Input/Output Specification –>
   <ioSpecification>
    <dataInput itemSubjectRef="tns:setToRequestItem" id="dataInputOfServiceTask" />
    <inputSet>
     <dataInputRefs>dataInputOfServiceTask</dataInputRefs>
    </inputSet>
    <outputSet />
   </ioSpecification>
   <dataInputAssociation>
    <sourceRef>dataInputOfProcess</sourceRef>
    <targetRef>dataInputOfServiceTask</targetRef>
    <assignment>
     <from>${dataInputOfProcess}</from>
     <to>${dataInputOfServiceTask.value}</to>
    </assignment>
   </dataInputAssociation>
  </serviceTask>

  <sequenceFlow id="flow2" sourceRef="webService"
   targetRef="waitState" />

  <receiveTask id="waitState" />

  <sequenceFlow id="flow3" sourceRef="waitState" targetRef="theEnd" />

  <endEvent id="theEnd" />

</process>
<!– Interface: implementationRef = QName of WSDL Port Type –>
<interface name="Counter Interface" implementationRef="counter:Counter">
  <!– Operation: implementationRef = QName of WSDL Operation –>
  <operation id="setToOperation" name="setTo Operation"
   implementationRef="counter:setTo">
   <inMessageRef>tns:setToRequestMessage</inMessageRef>
  </operation>
</interface>
<message id="setToRequestMessage" itemRef="tns:setToRequestItem" />
<itemDefinition id="setToRequestItem" structureRef="counter:setTo" /><!–
  QName of input element –>
</definitions>

jbarrez
Star Contributor
Star Contributor
Great that you got it working!

The webservice stuff is only limited documented, as we still haver to expand our coverage there.

fahad1
Champ in-the-making
Champ in-the-making
I want to reproduce the above bpmn for my own web service. When I deploy, I got the exception that
" one of the attribute class, delegate expression, type , operation is mandatory on service task"
When I am using the above method, Why activiti explorer gives me this error ? This is mandatory for the java service task as
<serviceTask id="javaService"   name="Java service invocation"  activiti:class="myservice.servicetask.MyJavaDelegate">

but here we are doing <serviceTask id="myServ" name="CallService" implementation="##WebService" operationRef="tns:sayHello">

In this case, why activiti explorer is producing this error ?

jbarrez
Star Contributor
Star Contributor
Probably you didn't add ' implementation="##WebService"' to your service task?

fahad1
Champ in-the-making
Champ in-the-making
thanks for your reply, but I add <serviceTask id="webService" name="Call WS" implementation="##WebService" operationRef="…">

but still I get the same error. Will there be any other JAR missing  ?? Why activiti explorer is not invoking it ?