User Guide

Table Of Contents
898 Chapter 36: Using Web Services
For information on displaying WSDL, see “Producing WSDL files” on page 900.
Since ColdFusion automatically handles mappings to ColdFusion data types, you can call this
web service as the following example shows:
<head>
<title>Passing queries to web services</title>
</head>
<body>
<cfquery name="GetEmployees" datasource="cfdocexamples">
SELECT FirstName, LastName, Salary
FROM Employee
</cfquery>
<cfinvoke
webservice = "http://localhost/echotypes.cfc?wsdl"
method = "echoQuery"
input="#GetEmployees#"
returnVariable = "returnedQuery">
<cfoutput>
Is returned result a query? #isQuery(returnedQuery)# <br><br>
</cfoutput>
<cfoutput query="returnedQuery">
#FirstName#, #LastName#, #Salary#<br>
</cfoutput>
</body>
Publishing web services
To publish web services for consumption by remote applications, you create the web service using
ColdFusion components. For more information on components, see Chapter 10, “Building and
Using ColdFusion Components,” on page 201.
Creating components for web services
ColdFusion components (CFCs) encapsulate application functionality and provide a standard
interface for client access to that functionality. A component typically contains one or more
functions defined by the
cffunction tag.
For example, the following component contains a single function:
<cfcomponent>
<cffunction name="echoString" returnType="string" output="no">
<cfargument name="input" type="string">
<cfreturn #arguments.input#>
</cffunction>
</cfcomponent>
The function, named echoString, echoes back any string passed to it. To publish the function as a
web service, you must modify the function definition to add the
access attribute and specify
remote, as the following example shows:
<cffunction name="echoString" returnType="string" output="no" access="remote">