cancel
Showing results for 
Search instead for 
Did you mean: 

Service parameters and return value

mhw
Champ in-the-making
Champ in-the-making
Hi, I am trying to interact with a service facade using XML only. I am stuck with how to pass parameters from outside expressions.

I have the following process:
<serviceTask id="javaService" name="Read voltage"
      activiti:expression="#{ServiceDelegate.execute()}"
      activiti:resultVariable="voltage">
      <extensionElements>
         <activiti:field name="serviceName">
            <activiti:string>READ_VOLTAGE</activiti:string>
         </activiti:field>
      </extensionElements>
   </serviceTask>
   <sequenceFlow id="flow2" sourceRef="exclusiveGw" targetRef="theTask1">
      <conditionExpression xsi:type="tFormalExpression">{voltage == 12.1}</conditionExpression>
    </sequenceFlow>

Now I want to access the filed "serviceName" from the execute-Method. Unlike realized with "activiti:class" the field is not injected. But I have to use "activiti:expression" since I need the "activiti:resultVariable".

Could anybody please help?

regards, Michael
10 REPLIES 10

trevershick
Champ in-the-making
Champ in-the-making
<serviceTask id="javaServiceReadVoltage" name="Read voltage"
   activiti:class="com.bigcompany.wfe.activiti.delegate.ServiceDelegate">
  <extensionElements>
   <activiti:field name="serviceName">
    <activiti:string>READ_VOLTAGE</activiti:string>
   </activiti:field>
  </extensionElements>
 
</serviceTask>

Michael

Perhaps it seems too easy or silly but couldn't you just pass in the name of the variable you wan tthe service task to return the result as with a meaningful default?
   <activiti:field name="responseVariable">
    <activiti:string>myResult</activiti:string>
   </activiti:field>

then in your code it's just execution.setVariable(responseVariable, "the result")?

that would allow the bpmn author to specify what var to use.