User Guide

Table Of Contents
904 Chapter 36: Using Web Services
<cfset tempname.Lastname = #empinfo.lastname#>
<cfset temp = ArrayAppend(returnarray, tempname)>
</cfloop>
<cfreturn returnarray>
</cffunction>
</cfcomponent>
When you invoke the web service, it returns an array of CFCs. Access the properties in the CFC
by using dot notation, as the following example shows:
<cfinvoke webservice ="http://localhost:8500/ws/cfcarray.cfc?wsdl"
method ="allNames"
returnVariable="thearray">
<cfif IsArray(thearray)>
<h1>loop through the employees</h1>
<p>thearray has <cfoutput>#ArrayLen(thearray)#</cfoutput> elements.</p>
<cfloop index="i" from="1" to="#ArrayLen(thearray)#">
<cfoutput>#thearray[i].firstname#, #thearray[i].lastname# </cfoutput><br>
</cfloop>
<cfelse>
<h1>Error: thearray is not an array</h1>
</cfif>
Publishing document-literal style web services
In addition to RPC-oriented operations, for which consumers specify a method and arguments,
ColdFusion also lets you publish web services using the document-literal style. When you use
document-literal style, the WSDL for the web service tells the client to use XML schemas rather
than RPC calling conventions.
In most cases, the publisher of a web services identifies it as document-literal or RPC style. To
identify the type, open the WSDL document and find the
soap:binding element and examine
its
style attribute, as the following example shows:
<wsdl:binding name="WeatherForecastSoap" type="tns:WeatherForecastSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
In this example, the style is document-literal. You must further examine the WSDL to determine
the methods you can call and the parameters for each method.
On the client side, the
cfinvoke tag and other ColdFusion methods for calling web services
handle this automatically. In most cases, no modifications are necessary. Similarly, when
publishing CFCs as document-literal style web services, ColdFusion automatically creates and
manages the appropriate WSDL.
To publish CFCs as document-literal style web services, specify
cfcomponent
style="document"
, along with the other attributes required for document-literal style web
services. For example, ColdFusion MX publishes the following CFC using document-literal style:
<cfcomponent style="document" >
<cffunction
name = "getEmp"
returntype="string"