invoke

Fusebox 4.1 introduced the invoke verb which allows you to call an object, class or webservice from the circuit.

In Fusebox 4.1, for <invoke>, you must specify the method name and the list of arguments together as a single attribute, methodcall, you can use the same syntax in Fusebox 5.

<!--- Fusebox 4.1 style invocation, also valid in Fusebox 5 --->
<invoke object="myObj" methodcall="foo(one='arg1string',two=arg2)" />

Given that ColdFusion's <cfinvoke> tag uses method to specify the method name and then either inline attributes or nested <cfinvokeargument> tags to specify the arguments in the method call, it was thought better to support a similar syntax.

Fusebox 5 adds the ability to specify the method name and the arguments separately, more in line with ColdFusion's syntax, allowing for both named arguments and positional arguments. The following form of <invoke> is now equivalent the above Fusebox 4.1 example:

<!--- Fusebox 5 style invocation with named arguments --->
<invoke object="myObj" method="foo">
<argument name="one" value="arg1string" />
<argument name="two" value="#arg2#" />
</invoke>

Note in particular the differences between strings and evaluated arguments in the two different forms of syntax.

This is how you can specify positional (unnamed) arguments in the two different forms of syntax:

<!--- Fusebox 4.1 style invocation, also valid in Fusebox 5 --->
<invoke object="myObj" methodcall="foo('arg1string',arg2)" />

<!--- Fusebox 5 style invocation with positional arguments --->
<invoke object="myObj" method="foo">
<argument value="arg1string" />
<argument value="#arg2#" />
</invoke>

This verb can also be used to instantiate the object as well as to call a method on an already instantiated object. In this case the syntax is different and the object argument is replaced by the class argument.

<!--- Fusebox 5 style instantiation and invocation with positional arguments --->
<invoke class="myClass" method="foo">
<argument value="arg1string" />
<argument value="#arg2#" />
</invoke>

To use invoke to call a web service the webservice parameter is used. For example:

<!--- Fusebox 5 style webservice call with positional arguments --->
<invoke webservice="www.someserver.com/webservice.wsdl" method="foo" returnvariable="returnedData" >
<argument value="arg1string" />
<argument value="#arg2#" />
</invoke>

Note that although the Fusebox 4.1 format (methodcall on <invoke>) is not deprecated in Fusebox 5 - it is possible that it may be deprecated in a future release of Fusebox.