User Guide
212 Chapter 2: ColdFusion Tags
</cfinvoke>
<cfoutput>#res#</cfoutput>
Example2
This example uses Syntax 1.
<!--- passing the arguments using argumentCollection --->
<cfset args = StructNew()>
<cfset args.symbol = "macr">
<cfinvoke
component="nasdaq.quote"
method="getLastTradePrice"
argumentCollection="#args#"
returnVariable="res">
<cfoutput>#res#</cfoutput>
Example3
This example uses Syntax 2.
<!--- called only from within a component, MyComponent--->
<cfinvoke
method = "a method name of MyComponent"
returnVariable = "variable name">
Example4
This example uses Syntax 3.
<!--- using cfinvoke to consume a web service using a ColdFusion component --->
<!--- put the following code in a ColdFusion page named wscfml.cfm:--->
<cfinvoke
webservice='http://www.xmethods.net/sd/2001/BabelFishService.wsdl'
method='BabelFish'
translationmode="en_es"
sourcedata="Hello world, friend"
returnVariable='foo'>
<cfoutput>#foo#</cfoutput>
For more information on the BabelFish web service example, see Chapter 32, “Using Web
Services,” in Developing ColdFusion MX Applications.
Example5
This example uses Syntax 4A.
<!--- separate instantiation and method invocation; useful for
multiple invocations using different methods or values--->
<cfobject
name="quoteService"
component="nasdaq.quote">
<cfinvoke
component="#quoteService#"
method="getLastTradePrice"
symbol="macr"
returnVariable="res_macr">
<cfoutput>#res#</cfoutput>
<cfinvoke
component="#quoteService#"
method="getLastTradePrice"
symbol="mot"
returnVariable="res_mot">
<cfoutput>#res#</cfoutput>