Marshaling and Unmarshaling, Serializing and Deserializing, Encoding and Decoding, whatever you prefer to call it, converting XML to an ActionScript object and back again can be a real chore. It’s a process that typically involves a lot of code to manage the points of connection between the AS object and the underlying XML representation. I’ve utilized various solutions to this problem in different projects: manipulating XML as the object changes via getters/setters, updating the XML in a bulk process with a toXML() function, or sometimes a combination of both. None of these solutions ever felt quite right. But short of convincing every backend developer that I work with to implement an AMF API, I couldn’t come up with a viable solution. I was stuck writing code to perform tasks that I didn’t think should be a part of my application’s core functionality.
Being a developer, and therefore lazy, I didn’t want to write my own library to perform marshaling/unmarshaling if someone else had already done so. I started searching on Google Code and Source Forge, and I found a couple of projects that did kind of what I wanted, but not exactly. FlexXB and FlexB were close, but I decided to write my own implementation.
So that brings us to ActionScript XML Binding (ASXB), which, while not a pure ActionScript implementation, could become one quite easily. Only a few classes from the Flex framework are utilized and are mostly logging classes. The other important Flex framework class is the mx.rpc.http.HTTPService, which I’ve extended as both a class to be instantiated in ActionScript (org.orpheus.xml.bind.XMLService) and an MXML extension (org.orpheus.xml.bind.mxml.XMLService). The XMLService class provides automatic handling of XML/ActionScript encoding and decoding.
This is the 0.1 release of ASXB, give it a try, and let me know what you think.