MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 720

Developing coldfusion mx applications
Table of Contents

Advertisement

The following example shows a ColdFusion component that takes a query as input and echoes
the query back to the caller:
<cfcomponent>
<cffunction name='echoQuery' returnType='query' access='remote'>
<cfargument name='input' type='query'>
<cfreturn #arguments.input#>
</cffunction>
</cfcomponent>
If you add this web service in Dreamweaver MX, you see a description of it in the Components
tab of the Application panel.
Note: This figure assumes that you create a web component named echotypes.cfc that contains the
echoQuery function definition shown above, and that you write the echotypes.cfc file to your web root
directory.
In the WSDL file for the echotypes.cfc component, you see the following definitions that specify
the type of the function's input and output as QueryBean:
<wsdl:message name="echoQueryRequest">
<wsdl:part name="input" type="tns1:QueryBean"/>
</wsdl:message>
<wsdl:message name="echoQueryResponse">
<wsdl:part name="return" type="tns1:QueryBean"/>
</wsdl:message>
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="CompanyInfo">
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>
720
Chapter 32: Using Web Services

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents