User Guide

Table Of Contents
912 Chapter 36: Using Web Services
You access elements of the variable myReturnVar using dot notation in the same way that you
access structure fields. If a complex type has nested elements, in the way a structure can have
multiple levels of nested fields, you use dot notation to access the nested elements, as in a.b.c.d, to
whatever nesting level is necessary.
However, the variable myReturnVar is not a ColdFusion structure. It is a container for the
complex type, but has none of the attributes of a ColdFusion structure. Calling the ColdFusion
function
isStruct on the variable returns False.
You can copy the contents of the variable to a ColdFusion structure, as the following example
shows:
<cfscript>
...
ws = createObject("webservice", "http://somehost/echosimple.asmx?wsdl");
myReturnVar = ws.echoStruct(stUser);
realStruct = structNew();
realStruct.active = #myReturnVar.active#;
realStruct.fname = "#myReturnVar.fname#";
realStruct.lname = "#myReturnVar.lname#";
realStruct.age = #myReturnVar.age#;
realStruct.hiredate = #myReturnVar.hiredate#;
realStruct.number = #myReturnVar.number#;
</cfscript>
Calling IsStruct on realStruct returns True and you can use all ColdFusion structure functions
to process it.
This example shows that ColdFusion variables and structures are useful for handling complex
types returned from web services. To understand how to access the elements of a complex type
written to a ColdFusion variable, you have to inspect the WSDL file for the web service. The
WSDL file defines the API to the web service and will provide you with the information necessary
to handle data returned from it.
Publishing web services that use complex data types
The two ColdFusion data types that do not map exactly to WSDL data types are struct and query.
When you publish a ColdFusion web service that uses parameters of type struct or query, the
consuming application needs to be able to handle the data.
Note: If the consumer of a ColdFusion web service is another ColdFusion application, you do not
have to perform any special processing. ColdFusion correctly maps struct and query data types in the
web service publisher with the consumer. For more information, see “Consuming ColdFusion web
services” on page 897.