Search code examples
wso2

WSO2 Call Template Mediator how to get a variable


I'm trying to use Call Template Mediator in WSO2 and I'm trying to get a dynamic value inside function, but I don't find the way to get it. For example:

<property expression="$ctx:variable" name="test" type="STRING"/>
<call-template target="HelloWorld_Logger">
<with-param name="message" value="VARIABLE: " expression="$ctx:test" />
</call-template>

I'm not able to get the property "test", if i remove value field the IDE reports an error. There is some way to get a property inside <call-template> function?


Solution

  • The Call Template Mediator doesn't have a parameter called expression to pass dynamic values. You must pass the XPath expression within {} to the value parameter itself. In your case, the call-template will be as follows,

    <call-template target="HelloWorld_Logger">
        <with-param name="message" value="{$ctx:test}"/>
    </call-template>
    

    Please refer to the Call Template Mediator for more information.