Skip to end of metadata
Go to start of metadata


Action Message Format (AMF) is a high-performance web services protocol that was developed and designed especially for Flash applications by Adobe. AMF is generally considered an RPC protocol (i.e. an optimized alternative to SOAP) because it defines a way to invoke remote methods from a Flash-based client.

Another significant part of the AMF specification, however, is the definition of a data serialization format. This serialization format makes AMF a viable representation (i.e. media type) for REST resources. This offers significant potential for Flash/Flex/ActionScript developers, since the availability of AMF representations for REST resources means that they could work with strongly-typed ActionScript classes without having to translate them to/from XML (or JSON or whatever other format). Instead, the objects could be written and/or read directly to a stream.

This tutorial is intended to show how to provide AMF REST resources in Java using freely-available APIs. How to provide AMF resources on other platforms (e.g. Ruby, .NET, PHP, etc.) is left for another day (and probably another author).


Here's what we do:

  1. Write the server-side data objects
  2. Write the client-side data objects
  3. Write the server-side resource methods
  4. Write the server-side AMF data provider
  5. Write the client-side invocation code
  6. Compile, build, and deploy

There's the hard way, and then there's...


Enunciate is a free build-time tool designed to make it easy to develop a rich Web-service API. As of version 1.10, Enunciate will automatically deploy your JAX-WS REST endpoints via AMF. It will also generate your client-side ActionScript data objects that can be used to consume these REST endpoints. With Enunciate, you simply write your server-side data objects and resource methods, and Enunciate will take care of the rest (no pun intended).

However, since there's value in knowing what's running under the hood, we continue on with the tutorial...

For this tutorial, we will be writing a simple address book application. We'll provide a contacts resource for reading the list of contacts and we'll provide a contact resource for updating contact information. We'll be using JAX-RS for defining our resource methods and providers, and BlazeDS for (de)serializing our Java objects to/from AMF.

Write the server-side data objects

Pretty basic POJOs:

Write the client-side data objects

The associated ActionScript classes are a reflection of the Java server-side classes. Of course, you have to do some translation, since not all Java types are ActionScript types and vice-versa. You can view some of the rules at Converting data from Java to ActionScript. Note also that if the name of your ActionScript object is different from that of your Java object, you need to register a "class alias" with the registerClassAlias method. (Here's where a code generator, like Enunciate, comes in really handy.)

Write the server-side resource methods

We just write a pair of simple JAX-RS resource methods. We'll refer you to other resources to learn more about JAX-RS. Note that the resource method produces and/or consumes media type "application/x-amf".

Write the server-side AMF data provider

Again, we use JAX-RS to supply a provider for AMF. Here's what it might look like:

Write the client-side invocation code

What you do with the data is up to you. But here's some sample code that shows how one might make a request to a REST resource and (de)serialize the data:


Compile, build, and deploy

This one's up to you. How you build and deploy is very environment-specific. It also depends on the JAX-RS implementation you're using. And of course, you've got to compile your Flex app, too...

Again, if you're using Enunciate, it's easy--Enunciate will package up everything in a war file for you, which you can drop in your favorite servlet container.

  • No labels


  1. I would like to propose not to wait until you earn enough money to buy goods! You can just get the personal loans or auto loan and feel free

  2. Comfortable viewing AMF files content is here:
    You can select a file from disk or download from this address
    and view it content as tree or as simple text.