User Guide

Table Of Contents
876 Chapter 35: Using XML and WDDX
Exchanging data across application servers
WDDX is useful for the transfer of complex, structured data seamlessly between different
application server platforms. For example, an application based on ColdFusion at one business
could use
cfwddx to convert a purchase order structure to WDDX. It could then use cfhttp to
send the WDDX to a supplier running a CGI-based system.
The supplier could then deserialize the WDDX to its native data form, the extract information
from the order, and pass it to a shipping company running an application based on ASP.
Transferring data between the server and browser
You can use WDDX for server-to-browser and browser-to-server data exchanges. You can transfer
server data to the browser in WDDX format and convert it to JavaScript objects on the browser.
Similarly, your application pages can serialize JavaScript data generated on the browser into
WDDX format and transfer the data to the application server. You then deserialize the WDDX
XML into CFML data on the server.
On the server you use the
cfwddx tag to serialize and deserialize WDDX data. On the browser,
you use WddxSerializer and WddxRecordset JavaScript utility classes to serialize the JavaScript
data to WDDX. (ColdFusion installs these utility classes on your server as webroot/CFIDE/
scripts/wddx.js.)
WDDX and web services
WDDX does not compete with web services. It is a complementary technology focused on
solving simple problems of application integration by sharing data on the web in a pragmatic,
productive manner at very low cost.
WDDX offers the following advantages:
It can be used by lightweight clients, such as browsers or the Macromedia Flash player.
It can be used to store complex data structures in files and databases.
Applications that take advantage of WDDX can continue to do so if they start to use web services.
These applications could also be converted to use web services standards exclusively; only the
service and data interchange formats—not the application model—must change.
How WDDX works
The following example shows how WDDX works. A simple structure with two string variables
might have the following form after it is serialized into a WDDX XML representation:
<var name='x'>
<struct>
<var name='a'>
<string>Property a</string>
</var>
<var name='b'>
<string>Property b</string>
</var>