User Guide

Table Of Contents
Consuming web services 891
Consuming web services
ColdFusion MX 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 in this section
The examples in this section 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 889.
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>
The operation name used in the examples in this section 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:
zipcode. When you call the getTemp operation, you pass the parameter as input.
Method CFML operator Description
CFScript CreateObject() Consumes a web service from within a CFScript block.
CFML tag
cfinvoke Consumes a web service from within a block of CFML code.
CFML tag
cfobject Consumes a web service from within a block of CFML code.