Static Bindings in Services pattern

An Erlang function defined as a service property can be referenced by any operation on that service. This way a function can be used by multiple operations. You can also bind functions to variables declared on the operation level.

In the example in Table 1, svc_expr is used to produce new field sets by assigning new values to a field, this time via static binding.
Table 1. Static bindings
Example Description
<service name="Expr"  
  provision="expr">  
  <prop name="expr.src"
    content-type="text/x-erlang"><![CDATA[
IncrFun =  
  fun(N) ->   
    N + 1  
  end.  
  ]]></prop>  

<consume name="Increment"  
  service="Expr"  
  fields="value">    

  <prop name="expr.bind.in"    
    Value="value"/>    

  <prop name="expr.bind.out"    
    NewValue="value"/>    

  <prop name="expr.src"
    content-type="text/x-erlang"><![CDATA[
NewValue = IncrFun(Value),
"Ok".  
  ]]></prop>    

  <reply name="Ok"    
    fields="value"/>
</consume>
The expr.src property of the service binds a function to the variable IncrFun.

This function can now be referenced in any operations on this service, such as the Increment operation.

Note: There is no need to declare static bindings in the XML markup. They are automatic, and all variables bound in the service expressions list are available to operations on that service.
Note: Do not manually type the <![CDATA...]]> delimiters. The Editor automatically renders text content as XML CDATA sections.