My take,

WDDX is a way of describing data structures... associative arrays,
recordsets, ordinary arrays, nested objects (like an array of recordsets
containing structures for example <ha>).  If what you need to do is exchange
"programming data structures" between 2 platforms or 2 servers without a lot
of rigamarol .... or if you want to easily store "data structures" in a form
that's easily accesible - the wddx is a great choice.  If you are going to
format XML for display, then maybe not.  More to the point, Wddx is really
easy to work with because the object that is returned is often a native
programming construct that's you are used to working with (rather than
traversing nodes etc.).

If you are using Cold Fusion, Wddx is especially a good choice because you
don't really have to know ANY xml to use it - just go ahead and use the
tags. For example, If I want to use a wddx data service (like finwin.com)
with CFML, I use the following code:

*****************
<cfhttp url="http://www.finwin.com/processct/processquotetag.cfm"; method =
"POST">
<cfhttpparam type="formfield" name="username" value="Bob">
        ..... some more form fields
</cfhttp>

<cfwddx action="WDDX2CFML" input="#cfhttp.filecontent#" output="myquery">

<cfoutput query="myquery">

#sym# - #last# - #volume# <br>
</cfoutput>

**********************

Just a few lines of code right?  Ok - now check out the a Java/JSP
implementation of wddx using my own Java util...  As you can see you have to
do a lot to use that "really good" JAXP parser - and don't get me wrong, it
IS really good - and fast.  It's just not as trivial as CF.  CF's
implementation of the WDDX parser is really quite a marvel if you ask me.

Mark

********************


import com.finwin.util.*;   // Needed for the WDDXDocument, WDDXObject, &
WDDXRecordset
import java.net.*;          // Needed for URL
import java.io.*;           // Needed for InputSource
import org.xml.sax.*;       // Needed for XML Parser Interfaces
import org.apache.xerces.parsers.*; // Needed for XML4J DocumentBuilder,
etc.
import org.w3c.dom.*;       // Needed for the DOM Interfaces

public class xml4jtest {

    public static void main(String args[]) {

        URL url=null;
        try { url = new
URL("http://www.finwin.com/processct/processquotetag.cfm";);
        } catch(MalformedURLException mue) {}

        HTTPRequest req = new HTTPRequest(HTTPRequest.POST, url);
        req.addPostValue("USERNAME", "" /* TODO: Specify your FinWin User
name here */);
        req.addPostValue("PASSWORD", "" /* TODO: Specify your FinWin
Password here */);
        req.addPostValue("ID", "" /* TODO: Specify your FinWin ID here */);
        req.addPostValue("request", "quote");
        req.addPostValue("TYPE", "query");
        for(int i = 0;i<args.length;i++)
            req.addPostValue("symbol", args[i]);
            int rc = req.request();             // make the request
        if (rc/100 == 2) { // a 2xx class response (ie. good)

            String wddx = req.getResponse();
            if (wddx!=null) {
                try {
                    DOMParser       parser = new DOMParser();
                    InputSource             is = new InputSource(new
StringReader(wddx));
                    parser.parse(is);

                    Document                doc = parser.getDocument();
                    WDDXDocument            wdoc = new WDDXDocument(doc);
               WDDXObject  obj = wdoc.getData();

                if (obj instanceof WDDXRecordset) {
                        WDDXRecordset   rs = (WDDXRecordset)obj;
                        String  cols[] = rs.getColumnNames();
                        int     rowCount = rs.getRowCount();
                        int     i,j;

                        System.out.println("\n\n\n");

                       System.out.println("Symbol, High, Low, Open, Close,
Last, Volume");
                        for(i=0;i<rowCount;i++) {
                            System.out.print(rs.getValue(i,"SYM"));
                            System.out.print(", "+rs.getValue(i,"HIGH"));
                            System.out.print(", "+rs.getValue(i,"LOW"));
                            System.out.print(", "+rs.getValue(i,"OPEN"));
                            System.out.print(", "+rs.getValue(i,"PREV"));
                            System.out.print(", "+rs.getValue(i,"LAST"));
                            System.out.println(",
"+rs.getValue(i,"VOLUME"));
                        }
                    } else {
                               System.err.println("Unexpected data received:
"+obj);
                    }
                } catch (SAXException e) {
                    e.printStackTrace();
                    System.out.println("wddx:"+wddx);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        } else {
            System.err.println("The server responded
with:"+rc+"\n"+req.getResponse());
        }
    }
}






-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 9:53 AM
To: CF-Talk
Subject: WDDX


I'm not sure if this is OT or not but here goes...



Why would I use WDDX instead of just using straight XML?

-there are SEVERAL good parsers out there.

-The javascript that it takes to create the "packets" is not that complex.

-The "packets" aren't really any kind of packets their just strings that
      are parsed...XML?

and more...



I actually am interested in using it and I have no direct quams with using
      WDDX but why would I use it when we have an XML framework already
      built for other applications?



Thanks-

Savan

______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to