question about rest xml and flash as3

My first project as an independent contractor is a Flash video application that makes some lightweight data calls to a Ruby on Rails backend. We experimented with RubyAMF and implemented a beta version using WebORB Ruby on Rails. Both of these remoting implementations worked well, but in the interests of deployment simplicity we decided to abandon remoting and simply do a REST architecture.

The timing is excellent because I had just been engaging in a debate with my former co-worker Brian Riley about the merits of the Representational State Transfer (REST) approach. Brian’s take was ‘Big deal, it’s xml over http. What’s different about using REST instead of querystring parameters?‘ I didn’t have a great answer for him. I muddled on about how it was a standardized vocabulary of create/update/delete through the GET, PUT, POST, and DELETE http methods. I pointed to framework implementations that make it quick to develop a REST interface which is reusable across different applications. But I didn’t make too good a case because I hadn’t yet built anything on REST and was basing my argument on faith instead of true implementation experience. One source of my faith in particular was a podcast interview I had heard with Tony Hillerson of Effective UI, who had advocated using REST with Rails instead of remoting.

So now that I had the opportunity to implement REST in Actionscript 3 on a project, I dug into it and quickly ran into a problem. The rock solid approach to loading XML into Flash is to use the UrlRequest and UrlLoader classes, however these only implement the GET and POST http methods. This leaves out the DELETE and PUT http methods that round out the REST vocabulary and make the relatively simple approach so powerful.

So I hunted around for the tutorial that would explain how to overcome this shortcoming of implementing REST in Flash Actionscript 3 . . . . and I struck out.

The Flex framework offers the HttpService class, which implements all the http methods:GET, POST, HEAD, OPTIONS, PUT, TRACE and DELETE. However, I’m using Flash and I don’t have the HttpService at my disposal. These are the types of things all those extra kilobytes in Flex applications get you.

I found a tutorial in french. Pourquois Flex? Pourquois ROR? Ou est le code example? This section appears to confirm my suspicions while indicating that the DELETE and PUT methods are unnecessary. However my french is terrible. Do I implement DELETE and PUT using ruby routes mappings? Is this really REST?

HTTP fournit les 4 operations de base du CRUD (POST pour CREATE, GET pour READ, PUT pour UPDATE, DELETE pour DELETE). Chaque operation est auto-suffisante. Utilisation des standards HTML et XML. Ce qu?il faut savoir est que tous nos navigateurs supportent les 2 verbes HTTP seulement : GET et POST. En fait il y en a beaucoup plus. Comme vu precedemment, avec 4 verbes HTTP on se mappe sur un CRUD (persistence en base). RoR va effectuer ce mapping (notamment grace a un mapping ?magique?, associant verbes, formats, headers de requetes). On verra lors de l?exemple, que RoR nous apporte sur un plateau la gestion de deux formats HTML et XML.

I also found the beginings of an open source REST implementation called as3-active-resource that has an interesting approach. It uses a direct socket ( to implement PUT and DELETE operations ( This looks promising, but I’m a bit wary of implementing a socket approach to support these additional http operations. The project has yet to release any code so I’m guessing it is not ready for primetime at this moment. A socket also defeats the goal of achieving simplicity by using REST.

Here is my question: What is best practice for implementing a full REST architecture with DELETE and PUT using Actionscript 3?


#1 Tony Hillerson on 07.10.07 at 1:18 pm

Well, luckily, Jonathan, there’s another HTTP client that doesn’t support the DELETE and PUT verbs: the web browser. To get around this limitation rails routing has a hack in it to allow puts and deletes: submit data as a POST with _method=delete or _method=put in it. Here’s a good reference post and another interesting post

As for your friend that argues that REST is just more xml rpc, tell him it’s more subtle than that:
It’s about not reinventing the wheel. REST is about exposing resources (nouns) through various methods (HTTP methods – the verbs). The Verbs have always been there since HTTP was defined (more added in 1.1), but RPC-style services have traditionally ignored them and passed verb information in the query string or in the payload. That’s overkill, and it’s more simple to use the tools that HTTP provides already.

The idea of REST is “method in the verb, scoping in the url, data in the payload”. I can highly recommend reading RESTful Web Services ( to frame the discussion.

#2 jon on 07.10.07 at 9:17 pm

Thank you greatly for the answer Tony. I’ll give it a spin and post any interesting parts of my implementation over the next few days.

#3 answer on rest xml and flash — Marston Development Studio on 07.12.07 at 2:35 pm

[…] this week I posted a question about REST xml and flash as3. Tony Hillerson of effectiveUI graciously provided an answer. To summarize, I wanted to know how to […]

#4 answer on rest xml and flash as3 — Marston Development Studio on 11.14.10 at 7:30 pm

[…] this week I posted a question about REST xml and flash as3. Tony Hillerson of effectiveUI graciously provided an answer. To summarize, I wanted to know best […]