User Guide Cancel

Invoke

 

Note:

As of ColdFusion (2021 release), CORBA has been removed. You can no longer use CORBA-related features, functions, and tags.

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])
invoke(instance, methodname [, arguments])
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>
<cfscript> obj = createObject("component","TestComponent"); invoke(obj,"function1",{a1="ColdFusion"}); </cfscript>
<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>
<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>
<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>

Get help faster and easier

New user?