serverside communication in Flex

The basic web service components are HTTPService and WebService.

HTTPService is roughly analogous to XMLHTTPRequest in AJAX/DHTML.  It sends plain text, but is typically used to return XML data from REST-like requests (simple HTTP GET/POST, etc.)

WebService is used for SOAP-style RPC access.

Adobe has Livecycle Data Services (LCDS) and BlazeDS for remoting .

LCDS and BlazeDS use AMF, the Actionscript Message Format, a binary data serialization that reduces the size and processing complexity of of XML formats.

BlazeDS is a subset of what’s available in LCDS, and includes ProxyService, RemoteService, and MessageService.

ProxyService is an HTTP Proxy, prinicipally used to get around the cross-domain security constraint.  [rant deleted]

RemoteService uses RPC-style communication, maintaining client-side objects in Actionscript and POJOs on the server that are managed by the data service.

MessageService uses a Publish/Subscribe method, similar to RSS.  Clients can both publish and subscribe to data services, which is polled either periodically, or with a ‘long poll’  that uses (I think) HTTP timeouts (e.g, chat.-style communication.)  Besides text messages, Actionscript objects can be sent either in the body or as headers.  It also includes support for streaming.

LCDS includes Real Time Messaging Protocol (RTMP) messages, which allow persistent connections. You can simulate a persistent connection with BlazeDS long polling, but this doesn’t scale very well.

Cold Fusion includes Flash Remoting, but I’m not interested in this, as I’m not working directly with either CF or Flash.

Third party libraries like AMFPHP, SaberAMF Zend AMF, WebORB, RubyAMF, PyAMF, AMF.NET, FlourineFX, etc., can talk directly to Flex apps via AMF natively in the various languages (PHP, Ruby, Python, .NET), and not needing the java-based BlazeDS/LCDS from Adobe.

There is another intereting protocol I don’t know much about called SWX, which is essentially a subset of the native flash format (SWF) in a similar way that JSON is a subset of Javascript designed for client-server object passing.  It looks quite interesting, but I don’t know how much functionality is built around it.  SWXFormat is currently implemented in PHP.

Clear Toolkit has something interesting called a Change Object, which they say is similar to what’s offered by Data Management Services in LCDS.   It looks particularly interesting for collaboration apps like Taskboard and Harvest.

Other interesting projects include:

GraniteDS aims to be an open source alternative to LCDS, geared towards EJB3, Seam, and Spring (Java frameworks.)

SpiceFactory has another open source remoting framework.  Pimento is for data managment and Cinnamon for remoting. (Parsley is an MVC framework also by SpiceFactory.)

Advertisements

3 thoughts on “serverside communication in Flex

  1. To add some clarification…

    mx:HTTPService is REST (in whichever flavor you’d like… json, xml, etc…) and mx:WebService is SOAP.

    However, you’re missing the best one… mx:RemoteObject.

    When you’re talking about AMF, that is RemoteObject. RubyAMF, AMFPHP, Zend, etc… they all use RemoteObject on the Flex side. BlazeDS, LiveCycle also use RemoteObject.

    • Also, I didn’t realize that HTTPService had a json adapter. That could make consuming some existing RESTful web services quite a bit easier.

      By the way, do you have any experience using SWX?

  2. My bad, I accidentally called it RemoteService.

    While BlazeDS has a remoting-service, you’re right that RemoteObject is the Flex component that communicates with it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s