tags:

views:

497

answers:

7

I'm working on a ColdFusion site where data is stored in WDDX packets inside a database and it's a real pain. (I have no idea why the values aren't just stored in another table.)

I've not used WDDX before and the only documentation I can find about it seems quite old. So I'm curious if anyone still uses WDDX, and if so, what for?

+3  A: 

We do, for page chunk configuration data in our CMS. The decision dates back to CF5, and I might use a simpler XML format now (the data stored is just a serialized hash of scalar values) but it's a handy way to avoid the overhead of extra multi-row queries for data that's needed every time the parent record is accessed.

I guess the documentation hasn't changed much as there's only so much you can write about a simple data serialization operation :)

<cfwddx action="cfml2wddx" input=#raw_data# output="encoded_data"/>
<cfwddx action="wddx2cfml" input=#encoded_data# output="decoded_data"/>
Pete Jordan
+5  A: 

I use WDDX for storing configuration values in a small app that requires no database. I could use an ini file and GetProfileString(), but WDDX is a lot more convenient.

It is XML, so in theory you could use it to do AJAX (in the original sense). Especially because there was no native support for JSON until CF8.

You could also use it as a input for XSL transformations, so you don't have to make up your own XML to represent CF data types like structs or queries.

Last but not least you can use it as an extensible way of storing varying structured data in a database (log messages that cover different cases, for example). I'm not sure why this is a pain in your case, but maybe it's more of an architectural problem than a WDDX problem (?).

It boils down to this: It is handy to have quick and simple, yet portable and safe (no Evaluate() or custom plumbing required) way of serializing and de-serializing (i.e. "storing" or "persisting") any CF data type.

Tomalak
Thanks for that. In my case, the WDDX is storing user permissions in a CMS. The problem for me is that I can't simply query the db for a users permission. But as you say, it's an architectural issue, not a problem with WDDX itself.
nedlud
Hm, if you happen to be on SQL Server 2005+, there is an XML data type that you could use instead of NVARCHAR (or such). Other "feature-focused" DBMS may provide a similar thing.
Tomalak
+1  A: 

I've used it for a variety of reasons. One such was to allow a webservice-like functionality between two disparate ColdFusion servers. Since it's just a flavor of XML and, thus, plain text, it required nothing more complicated than a simple HTTP call using CFHTTP. And, since it's WDDX, it translated very easily back into CF structures.

Back in the CF5 days this was really important. Even now, when CF offers some pretty powerful tools for XML parsing, the native data structures are still easier to work with.

Al Everett
A: 

The last time I used it was to serialize the form scope. Can't remember much about why I needed to, but that the form had many variations and to repopulate the fields I could deserialize the WDDX and all was well with the world.

Haven't used it in a while now.

Adrian Lynch
A: 

I use to store some information about product shipping- which products go in which boxes, basically. At the time of the design of this application, there was no need to store that information in separate rows in the DB, so the struct that was built containing that information was serialized with WDDX and stuffed in the DB.

Clint Miller
+1  A: 

Ever since CF8 is out, I've used JSON instead of WDDX.

Both are great for serializing some data fields that don't need to be query against, while keeping the DB unchanged. I'll take JSON over WDDX any day. :)

Henry
I'm with Henry on this!
Adrian Lynch
A: 

I had to use it to store structures in cookies because I worked for an assclown company that built e-commerce websites with the session variable scope disabled. This wasn't for any kind of practical user security reason. Their back end administrative application for some unknown reason would cave in on itself if run on a server with session variables enabled. So instead of, you know, maybe fixing whatever was causing the problem, or perhaps running the admin system on a separate server, they disabled sessions, because it was the 'fastest, cheapest, and easiest' way to fix the problem.

So glad I don't work there anymore.

KeRiCr