Invokes an object method and returns the result of the invoked method.
invoke(instance, methodName [, arguments])
returns any
Name | Type | Required | Default | Description |
---|---|---|---|---|
instance | string | Yes | Name or instance of a CFC or an instance of a Java, .NET, COM or CORBA object to instantiate. For a CFC, it can be an empty string when invoking a method within the same ColdFusion page or component. | |
methodname | string | Yes | The name of the method (or operation for webservice) to invoke. | |
arguments | any | No | An array of positional arguments or a struct of named arguments to pass into the method. |
Invokes the size method on a new HashMap object, which should return 0
invoke(createObject("java", "java.util.HashMap"), "size")
Invokes the method named ‘test’ on the component Test.cfc with one parameter
obj = createObject("component", "Test");
invoke(obj, "test", {parameter="Test Data"});
Invokes the method named ‘test’ on the webservice Test.cfc with one argument
obj = createObject("webservice", "https://example.com/test.cfc?wsdl");
invoke(obj, "test", {argument1="Test Data"});
Invokes the method named ‘test’ on the webservice Test.cfc with multiple arguments
obj = createObject("webservice", "https://example.com/test.cfc?wsdl");
invoke(obj, "test", {argument1="Test Data", argument2="More Data", argument3="Still More Data"});