Skip to main content

REST Resources for Flash Developers

Posted by stoicflame on March 13, 2009 at 3:14 PM PDT

Over at FamilySearch, I've been involved in supporting Flash application development that consumes a public POX API. It's not a REST API, but like REST, we provide a set of resources that are accessible at a given URI. Up to this point, our Flash developers have been stuck with parsing the resources as XML. It works fine, but it's not without a significant overhead. XML isn't the most efficient data format, nor is it very convenient to work with in ActionScript code.

The "native" data format for flash development is AMF. When ActionScript objects get written to a stream, they are serialized as AMF. When the objects are read from a stream, AMF is the presumed deserialization format. The Enunciate project has provided support for supplying SOAP endpoints as AMF services for quite some time now, but I've only recently added support for AMF REST endpoints.

Here's the wrap-up of the process. As mentioned in the article, if you're already using Enunciate, this process will be significantly simpler. Enunciate already comes with a JAX-RS provider that does the serialization and it will generate your client-side ActionScript classes for you. Not to mention the fact that Enunciate will also generate documentation for your API and neatly package it up, ready to be deployed into your favorite servlet container.

Related Topics >>


Web design involves the

Web design involves the structure of the website including the information architecture (navigation schemes and naming conventions), the layout HughesNet Satellite or the pages (wireframes or page schematics are created to show consistent placement of items including functional features), and the conceptual design with branding.

Example enunciate.xml to generate REST docs

Hi Ryan, I like the enunciate framework and just started exploring it. Is it possible to provided simple examples to generate REST docs for existing Jersey REST APIs. We have developed of Jersey REST APIs. However they don't strictly follow the API-Impl code structure. They are simple POJOS with Jersey REST annotations. Could you provide some enunciate.xml examples that I can use to do the following: a) Generate REST docs including wadl and xsd schema b) AMF client side libraries Here is my enunciate.xml -- however it is not discovering nor generating AMF client side code: any clues? I am using enunciate-20 Regards --Mahesh

Re: Example enunciate.xml to generate REST docs

The latest versions of Enunciate require you to explicitly add the amf module to the dependency classpath in order for your AMF classes to be generated. So take a look at and replace all references to enunciate-rest and enunciate-rest-rt to enunciate-amf and enunciate-amf-rt.

Re: Api-Impl code structure: it doesn't matter, if it's a valid JAX-RS endpoint Enunciate will honor it. It doesn't have to be separated by interface/impl.


How are generating json and xml response

Thanks now I am able to generate AMF code too. It looks like there is AMF java server side domain object code too that has the same name as the original, under a different java package. This will be an issue for any existing large legacy APIs and domain objects. BTW, after doing a deep diving into the generated code, and as well as looking into the jersey services API/impl and the generated jersey artifacts, I couldn't figure out how enunciate is supporting both json and xml media types. No where I see @Consumes and @Produces annotations.

Re: How are generating json and xml response

Re: generated amf server-side code: the idea is that there needs to be a "bridge" between the objects that blazeds knows how to serialize and the JAXB objects, since BlazeDS doesn't honor JAXB annotations. I'm aware that the amount of generated code is heavy, but it's never really been too big of an issue, even for large legacy codebases.

Re: supporting xml and json: both formats are supported via standard JAX-RS mechanisms. If your resource method needs to consume/produce json, it needs to be annotated with @Consumes, @Produces appropriately.