where:
•
specifies the URL to the WSDL file for the web service.
webservice
•
specifies the operation of the web service to invoke.
method
•
specifies an input parameter passed to the operation.
inputParamN
•
specifies the name of the variable that contains any results returned from the
returnVariable
web service.
To access a web service using cfinvoke:
Create a ColdFusion page with the following content:
1
<cfinvoke
webservice = "http://www.xmethods.net/sd/2001/BabelFishService.wsdl"
method = "BabelFish"
translationmode = "en_es"
sourcedata = "Hello world, friend"
returnVariable = "foo">
<cfoutput>#foo#</cfoutput>
Save the page as wscfc.cfm in your web root directory.
2
View the page in your browser.
3
The following string appears in your browser:
Hola mundo, amigo
You can pass parameters to web services using two other mechanisms: the
and the
argumentCollection
To pass parameters using the
the following code shows:
<cfinvoke
webservice ="http://www.xmethods.net/sd/2001/BabelFishService.wsdl"
method ="BabelFish"
returnVariable = "varName" >
<cfinvokeargument name="translationmode" value="en_es">
<cfinvokeargument name="sourcedata" value="Hello world, friend">
</cfinvoke>
<cfoutput>#varName#</cfoutput>
The
cfinvokeargument
value of a parameter passed to the web service.
You can also use an attribute collection to pass parameters. An attribute collections is a structure
where each structure key corresponds to a parameter name and each structure value is the
parameter value passed for the corresponding key. The following example shows an invocation of
a web service using an attribute collection:
<cfscript>
stArgs = structNew();
stArgs.translationmode = "en_es";
stArgs.sourceData= "Hello world, friend";
</cfscript>
attribute of the
cfinvokeargument
tag is a nested tag of the
tag.
cfinvoke
tag, you write your call to the web service, as
tag that lets you specify the name and
cfinvoke
Consuming web services
tag
cfinvokeargument
715
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers