User Guide

Table Of Contents
Publishing web services 903
The following code defines a component in the file name.cfc that defines first and last name
properties:
<cfcomponent>
<cfproperty name="Firstname" type="string">
<cfproperty name="Lastname" type="string">
</cfcomponent>
You can then use address and name to define data types in a ColdFusion component created to
publish a web service, as the following example shows:
<cfcomponent>
<cffunction
name="echoName" returnType="name" access="remote" output="false">
<cfargument name="input" type="name">
<cfreturn #arguments.input#>
</cffunction>
<cffunction
name="echoAddress" returnType="address" access="remote" output="false">
<cfargument name="input" type="address">
<cfreturn #arguments.input#>
</cffunction>
</cfcomponent>
Note: If the component files are not in a directory under your web root, you must create a web server
mapping to the directory that contains them. You cannot use ColdFusion mappings to access web
services.
The WSDL file for the web service contains data definitions for the complex types name and
address. Each definition consists of the elements that define the type as specified in the
ColdFusion component file for that type. For example, the following example shows the
definition for name:
<complexType name="name">
<sequence>
<element name="firstname" nillable="true" type="soapenc:string"/>
<element name="lastname" nillable="true" type="soapenc:string"/>
</sequence>
</complexType>
You can also specify an array of CFCs in the returnType attribute, as the following example
shows:
<cfcomponent>
<cffunction
name="allNames" returnType="name[]" access="remote" output="false">
<cfset var returnarray = ArrayNew(1)>
<cfset var temp = "">
<cfquery name="empinfo" datasource="cfdocexamples">
SELECT firstname, lastname
FROM employee
</cfquery>
<cfloop query="empinfo" >
<cfobject component="name" name="tempname">
<cfset tempname.Firstname = #empinfo.firstname#>