Description

Does either of the following:

  • Invokes a component method from within a ColdFusion page or component
  • Invokes a method on an instantiated web service object
  • invokes a method on Java/.NET/COM/Corba object

Returns

Returns what is returned by the invoked method.

History

ColdFusion 10: Added this function

Syntax

invoke(instance, methodname [, arguments])

Properties

Parameter

Description

instance

Required.

For CFC : String or component object; a reference to a component, or component name/path to instantiate. Can be an empty string when invoking a method within the same ColdFusion page or component.

For webservice/Java/.NET/COM/Corba : object instance

methodname

Required. Name of a method. For a web service, the name of an operation.

arguments

Optional. Arguments to pass to the method.

Example

Invoke a method on Component

<cfscript> 
obj = createObject("component","TestComponent"); 
invoke(obj,"function1",{a1="ColdFusion"}); 
</cfscript>

Invoke methods on a webservice

<cfscript> 
obj = createObject("webservice","http://somedomain/test.cfc?wsdl"); 
//Invoke foo 
result = invoke(obj,"foo",{arg1="ColdFusion"}); 

//Invoke bar with two arguments, passing the second argument as null.
result = invoke(obj, "bar", {arg1="ColdFusion", arg2=javacast("null", "")});
</cfscript>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy