You are on page 1of 29

Lesson 5

Database Interactivity and WDDX

Simeon Simeonov and Dick Steflik


1
Agenda

• The need for Web distributed data exchange


• The crisis of web applications
• The need for XML middleware
• Web Distributed Data Exchange (WDDX)
• WDDX scenarios
• Demos
• Call to action
2
Metcalf’s Law of Connectivity

• Metcalf’s Law of Connectivity


– The value of a network is a function of the
number of nodes connected to that network;
value grows exponentially with each node
• The Web is the new computing platform
– The number of nodes on the Net is huge, and
growing at an ever increasing rate, so...

3
Have we Achieved World Peace?
• One big assumption does not hold true
– Network nodes leverage peers’ data and
services
– A Web system must be a data and service
portal, not just an outward facing end-user
application
• Web applications are not so designed
– Most view web applications as having a fixed
end-user base working through web browsers
– The combination of HTML + script provides no
separation of data and processing 4
Case: FedEx Package Tracking
• Individuals track packages via browsers, but...
• FedEx’s real customers are corporations
– They want to integrate their order tracking
systems with FedEx’s package tracking system
– They cannot do this using the existing system
• Redesign requires “public data interfaces”
– Requires exchange of structured data between
browsers and servers and in between servers

5
The Crisis of Web Applications
• Structured data exchange is not happening
– HTTP is a flat text-based protocol
– Browsers are data-starved; despite ever
increasing processing capabilities, they do little
more than user-interface related work
– Servers are separated by the walls imposed by
under-powered data exchange
• Solution
– Break these walls down; let web applications
execute on the entire network
– We know XML can help! But, how? 6
Native XML Approach

• DTD design
• XML data generation
• XML parsing and processing
– SAX, DOM, …
• XML transformation
– CSS, DSSSL, XSL, …

7
Sounds Great, But…

• Native XML processing is still not very


easy
– XML is a young field
– The standards landscape is in flux
– Many tools are immature and/or expensive
– Mass developer community lacks expertise
• How can the Web take advantage of the
benefits of XML in this environment?
8
The Need For XML Middleware

• Solution
– A mechanism for exchanging structured data
that hides the details of XML processing
• What is required?
– The Web is simple, pragmatic, and ubiquitous
– Page-based web applications that run on web
application servers (Perl scripts, Active Server
Pages, ColdFusion) rule the field
9
How should it be done?
• Work directly with application data
– Developers never see XML, but they benefit from it
• Cross platform
– Different OSs: Windows, Mac, Unix
– Different languages: ColdFusion Markup Language
(CFML), VBScript, JavaScript, Java, C/C++,
COM, CORBA, Frontier, Perl, PHP, Python
• Open and flexible
– Easy to contribute to
– Can track evolving W3C standards
• Free! 10
How should it work?
Application Data

Platform X Serialization

The
Net

Platform Y
Deserialization

Application Data

11
Web Distributed Data Exchange
• WDDX DTD
– Language and platform neutral representation of
common application data structures: strings,
numbers, booleans, date-time values, arrays,
associative arrays, and recordsets
• WDDX platform modules
– Serialization/deserialization modules for CFML,
COM (C/C++, ASP, and all Windows apps),
JavaScript (browser), Perl, and Java
• WDDX datatypes
– Common API uses native datatypes when possible
12
Technology Comparisons
• XML DTDs
– WDDX abstracts the process of DTD creation, XML
generation, and XML parsing for app data
• DOM
– WDDX is an API built on top of DOM
• SOAP and WebBroker
– WDDX is about data, not object method requests
• WIDL
– WDDX has no notion of a service or an interface
• RDF and DCD
– WDDX is not about meta-data
13
WDDX Evolution
• WDDX DTD is versionable
– Multiple versions of WDDX can interoperate
– WDDX can track evolving W3C standards
• Source code is open
– Encourages involvement and participation
– Lowers the cost of WDDX-enabling a platform
– Allaire is working together with third parties
• It’s free!
– The more nodes speak WDDX, the better
14
When Should One Use WDDX?
• Point-to-point data exchange
– No pre-existing XML/SGML content
– Application-level data is ‘produced’
– Applications ‘consume’ the data
– Only one use for the XML data representation
• Multiple ad hoc data exchanges
– Little or no benefit from custom vocabularies
– Example: per page browser-server data
exchange
15
WDDX Scenarios
ColdFusion WDDX
Server XML

The
Net

CF Server
XML
WDDX

Windows/Java ASP Server


Client

JavaScript Browser

16
Web Technology Adoption Path
• XMLless Web
– Structure, where art thou?
• XML middleware
– Browsers and servers exchange structured data
– Developers can benefit from WDDX now
– Proof of XML benefits to the enterprise
• XML-enabled Web
– A better place for all

17
Call to Action
• Want to see WDDX in action?
– Download ColdFusion: www.macromedia.com
– Visit the WDDX site: www.openwddx.org
• Want to try WDDX out?
– download Software Development Kit (SDK)
from www.openwddx.com
– Send email to beta@allaire.com. It’s free!

18
the WDDX SDK

• What is in the SDK


– COM / ActiveX Implementation
– Java Implementation
– JavaScript Implementation
– Perl Implementation
– PHP Implementation
– ColdFusion Implementation
– "A2Z" Example Database
19
COM/ActiveX Implementation
• set of DLLs (that must be registered) that
implement the required XML parser and
WDDX components
• Server-side ActiveX
• Plugs into IIS for ASP use

20
Java Implementation

• The Java implementation is distributed as a


.jar archive of compiled .class files, and as
source .java files. You will use these files
with whatever Java development tool (or
JDK) that you are using

21
JavaScript Implementation
• The JavaScript implementation is distributed as
three JavaScript (.js) files. The "core" file is
wddx.js, which defines the WddxRecordset and
WddxSerializer objects.
• Additionally, the archive includes wddxDes.js,
which defines the WddxDeserializer object, and
wddxRsEx.js, which provides additional
functionality for recordset objects.

22
Perl Implementation

• A brand-new WDDX.pm module for Perl


has been graciously contributed to the
SDK by Scott Guelich. The module
provides the same kind of support as the
other implementations, including
serialization, deserialization, and the new
binary support

23
PHP Implementation

• The support is not distributed as part of the


SDK at this time.
• to find out more you can find out more
about the PHP/WDDX functionality,
including reference documentation, at
http://www.php.net/manual/ref.wddx.php3

24
Cold Fusion Implementation

• The Cold Fusion implementation is


included in Cold Fusion 4.0 and later
versions
• Currently, JavaScript support for WDDX
does not provide a way to deserialize a
WDDX packet. The server will deserialize
it into Javascript and deliver it to the
requesting browser
25
WDDX to Javascript

• to deserialize a WDDX packet to Javascript


at the browser some additional scripts are
required:
– wddxDes.js - Nate Weiss
– xparse.js - Jeramie Miller
• search the web for the file names, they are
in a number of places

26
Basic concepts
Take a native object; serialize it into a WDDX packet
Send it across the network
Deserialize it back into a native object

Serializing the native objects into WDDX packets gives us al way of of moving
environment specific (Java, CF,Perl…) objects around the network and
delivering them to the same environment or another other environment

27
example
select FirstName,LastName,Email from Employees
produces a ColdFusion record set, serialixing the recordset produces a WDDX packet

<wddxPacket version='0.9'>
<header></header>
<data>
<recordset rowCount='5' fieldNames='FIRSTNAME,LASTNAME,EMAIL'>

<field name='FIRSTNAME'>
<string>Carolynn</string>
<string>Dave</string>
<string>Linda</string>
<string>Aaron</string>
<string>Peter</string>
</field>
<field name='LASTNAME'>
<string>Peterson</string>
<string>Heartsdale</string>
<string>Stewart</string>
<string>Smith</string>
<string>Barken</string>
</field>
<field name='EMAIL'>
<string>CPETERSON</string>
<string>FHEARTSDALE</string>
<string>LSTEWART</string>
<string>ASMITH</string>
<string>PBARKEN</string>
</field>
28
</recordset>
deserialized into Javascript

EmployeeData=new WddxRecordset();_t2=newArray();_t2[0]="Carolynn";_t2[1]="Dave";_t2[2]="Linda";
_t2[3]="Aaron";_t2[4]="Peter";EmployeeData.firstname=_t2;_t2=newArray();_t2[0]="Peterson";
_t2[1]="Heartsdale";_t2[2]="Stewart";_t2[3]="Smith";_t2[4]="Barken";EmployeeData.lastname=_t2;
_t2=newArray();_t2[0]="CPETERSON";_t2[1]="FHEARTSDALE";_t2[2]="LSTEWART";_t2[3]="ASMITH";
_t2[4]="PBARKEN";EmployeeData.email=_t2;_t0=null;_t1=null;_t2=null;

Note that because of the serialization and deserialization


that the object that started out as a ColdFusion recordset
has ended up as a set of Javascript arrays

29