
1098
DEVELOPING
COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
Las
t
upda
te
d 8/5/2010
For additional descriptions of the contents of this WSDL file, see “
Consuming web services
” on page 1098.
Consuming web services
ColdFusion provides a variety of methods for consuming web services. The method that you choose depends on your
ColdFusion programming style and application.
The following table describes these methods:
One important consideration is that all consumption methods use the same underlying technology and offer the same
performance.
About the examples
The examples shown here reference the TemperatureService web service from
XMethods
. This web service returns the
temperature for a given ZIP code. You can read the WSDL file for this web service in “
Reading a WSDL file
” on
page 1096.
The TemperatureService web service has one input parameter, a string that contains the requested ZIP code. It returns
a float that contains the temperature for the specified ZIP code.
Passing parameters to a web service
The message and operation elements in the WSDL file contains subelements that define the web service operations
and the input and output parameters of each operation, including the data type of each parameter. 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>
fault
(not shown) Optionally specifies an error message returned from the operation.
binding
Specifies the protocol used to access a web service including SOAP, HTTP GET and POST, and MIME.
service
Defines a group of related operations.
port
Defines an operation and its associated inputs and outputs.
Method
CFML operator
Description
CFScript
()
Consumes a web service from within a CFScript block.
CFML tag
Consumes a web service from within a block of CFML code.
CFML tag
Consumes a web service from within a block of CFML code.
Component
Definition