Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1104

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
The operation name used in the examples is getTemp. This operation takes a single input parameter defined as a
message of type getTempRequest.
You can see that the message element named getTempRequest contains one string parameter:
the getTemp operation, you pass the parameter as input.
Handling return values from a web service
Web service operations often return information back to your application. You can determine the name and data type
of returned information by examining subelements of the message and operation elements in the WSDL file.
The following example shows a portion of the WSDL file for the TemperatureService web service:
<message name="getTempRequest">
<part name="zipcode" type="xsd:string"/>
</message>
<message name="getTempResponse">
<part name="return" type="xsd:float"/>
</message>
<portType name="TemperaturePortType">
<operation name="getTemp">
<input message="tns:getTempRequest"/>
<output message="tns:getTempResponse"/>
</operation>
</portType>
The operation getTemp returns a message of type getTempResponse. The message statement in the WSDL file defines
the getTempResponse message as containing a single string parameter named
Using cfinvoke to consume a web service
With the
tag, you reference the WSDL file and invoke an operation on the web service with a single tag.
cfinvoke
The
tag includes attributes that specify the URL to the WSDL file, the method to invoke, the return variable,
cfinvoke
and input parameters. For complete syntax, see the CFML Reference.
Note: You can pass parameters to a web service using the
the
tag itself. For more information, see
cfinvoke
page 196.
Access a web service using cfinvoke
1
Create a ColdFusion page with the following content:
<cfinvoke
webservice="http://www.xmethods.net/sd/2001/TemperatureService.wsdl"
method="getTemp"
returnvariable="aTemp">
<cfinvokeargument name="zipcode" value="55987"/>
</cfinvoke>
<cfoutput>The temperature at ZIP code 55987 is #aTemp#</cfoutput>
Save the page as wscfc.cfm in your web root directory.
2
View the page in your browser.
3
You can omit a parameter by setting the
ColdFusion sets the associated argument to null. If the WSDL specifies minoccurs=0, ColdFusion omits the argument
from the WSDL. However, CFC web services must still specify
cfinvokeargument
"Passing parameters to methods by using the cfinvoke
attribute to
. If the WSDL specifies that the argument is nullable,
omit
"yes"
required="true"
Last updated 1/20/2012
. When you call
zipcode
.
return
tag or by specifying parameter names in
tag" on
for all arguments.
1099

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents