Welcome, Guest
  • Author Topic: Flash Remoting - a technical explaination and resources  (Read 5868 times)

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Here's some decent info I found on Flash remoting and some of the technical aspects of it:

    This is a quote from Sean Neville Who spent some time working on building the Flash Remoting Format (AMF).  
    Quote
    By: Sean Neville

    Having spent the majority of the past year working on both JRun 4 and Flash Remoting for J2EE and .NET, the relation between Flash and J2EE (beyond ColdFusion) is of great importance to me and to the other engineers who pulled the products together. Although official announcements and docs will continue to flow through marketing and product management, here are some unofficial notes from engineering on the topic.

    Flash Remoting -- distinct from the low-level network I/O and XMLSocket available in Flash -- is an asynchronous RPC model that allows Flash to invoke methods directly on web services, EJBs, JavaBeans, JMX MBeans, POJOs, ColdFusion pages, ASP pages, and a number of other resources in the ColdFusion and .NET worlds that are probably less important to you than the Java cases. This model uses a binary message format (called Action Message Format, or AMF) that is delivered over HTTP and is modeled on SOAP, though it is much smaller and faster that standard SOAP and is purely asynchronous and event-driven in order to meet the Flash player requirements. It allows you to send a variety of data types -- RecordSets, full Java objects, primitives such as integers, Strings, XML Documents, references to EJBObjects, Dates, etc. -- across the wire. Passing ValueObjects through existing EJB-based apps to Flash clients is certainly possible. A gateway on the server handles conversion of these various types from their ActionScript (ActionScript is the ECMA script syntax used in authoring Flash) versions to their Java versions and vice versa (the .NET version of Flash Remoting does the same for CLR/CLS types). This gateway is designed as a front controller to server processes, and contains a number of filters to handle issues such as serialization, logging, security, etc. before handling the actual invocation of the targeted service. The .NET version follows a similar architecture, although it was written from the ground-up in C# instead of Java and is packaged and deployed differently.

    The client-side scripting model involves setting a connection to the gateway URL -- and due to security sandbox concerns, a client delivered over HTTP is permitted to access a gateway only on the host that delivered the movie, ala Java Applets -- and invoking the getService(...) method from the gateway connection. A "service" can be any server-side resource mentioned above, and the client assumes it exposes "functions" that can be invoked in the movie. If the remote service is an EJBHome, then the service functions are the EJBHome methods; if the service is a web service, the service's functions are the same as the web service's methods; if the service is a web context, then the service functions are ASP or CF pages available in that directory; etc. Through ActionScript, typically in response to client events such as clicks or data input, a service's functions are invoked and the results are asynchronously (everything in Flash is asynchronous) returned to the movie, typically causing the movie to update in some manner. Regardless of whether the remote gateway is hosted in a J2EE, CF, and/or .NET environment, the client-side API is the same. A single Flash client might connect to both .NET and J2EE resources, but it does so with the same API.

    There are other elements -- we included a data binding API so that RecordSets and other relational data can be directly bound to Flash UI components, for example, and added a debugger and service browser to aid in development, and numerous new UI components -- but this summarizes the basic approach.

    There are two parts of the Flash Remoting product: client ActionScript extensions and a server gateway. The client extensions are free, but the server gateway is implemented as a J2EE application (packaged as an EAR) that currently ships in JRun 4 and ColdFusion, and will soon be available elsewhere through partnerships with IBM and Sun. If you download JRun 4 or CF, you'll get this EAR as part of the install. I'm not yet sure how it will be productized in other application servers, but if not embedded I imagine it will be available for sale (look for official announcements as they occur).

    For more information about Flash Remoting, I'd recommend downloading either JRun or ColdFusion (the default ColdFusion standalone version is now a web app that runs on an embedded version of JRun, essentially JRun with a large taglib and different web admin, though it will be released for other app servers as well) and fiddling with the Flash Remoting samples and bundled documentation there. Alternatively, you can grab Flash Remoting for WebSphere or for .NET in a beta program, if you're working with either of those platforms, and fiddle with the samples and docs we include for those versions. There are certainly opportunities for improvement in the future, but the current MX launch in conjunction with the pending release of JRun 4 is a terrific start toward enriching J2EE development with extremely powerful media-rich clients.

    [/code]

    The entire article can be found here:
    http://www2.theserverside.com/home/thread.jsp?thread_id=13246

    Along with some other comments.

    Here are some additional Remoting Links:

    The format of the shared object files (also AMF) on Flashcoders Wiki
    http://chattyfig.figleaf.com/flashcoders-wiki/index.php?.sol

    http://www.evolt.org/article/Flash_Remoting_Demystified/17/48594/

    http://radio.weblogs.com/0106797/categories/flashForward/2002/07/11.html#a188

    http://www.macromedia.com/support/flash_remoting/releasenotes/mx/releasenotes.html
    « Last Edit: 01/17/03, 04:41 by Flash-db »
    Flash-DB

    stf

    • Server what's that
    • *
    • Posts: 3
      • View Profile
      • Email
    Many thanks for these insights! I still have some questions: You say AMF/Remoting  is "Modeled on SOAP" - what was the most compelling reason to invent something new and proprietary instead of just using soap?

    You stated three reasons:
    - size
    - speed
    - asynchronous invocation

    size: Did you do any experiments in implementing SOAP or XML-RPC inside flash and came up with some thing much huger than NetServices.as? Do you have any experiences, how large a SOAP or XML-RPC library for flash would be (I think the XML-support in Flash would be sufficient, whats left is the parsing of the enevlope and the Mappings into flash -arrays or objects.) Comparable libs in java can be kept quite small depending on the functionality.

    speed: this is obviously a SOAP-Problem that has nothing to with Flash; binary formats have less overhead and better support for compression -  anyway, even bigger companies like MS move away from binary formats - was there some flash-specific reason to use a binary format? The size-difference between a message in binary-format or as XML becomes the more relevant, the bigger the Data-Chunks become - but i doubt, that a design that forces a Flash-Client to read huge piles of data is efficient anyway: So the main-case will be small to medium-sized chunks - do you have any experiences with the size-difference between the AMF and a SOAP/XML-RPC based format?!

    asynchronous-invocation: I have a general Question about the asynchronous nature of the Remoting calls: With remoting, you generally call components with synchronous methods (e.g. a Method on a Session-Bean always works synchronous)  - but in the Remoting-Calls, the invocation and the result is decoupled ( via service.callMethod and an onResult-handler): Where does this transformation synchronous to asynchronous take place? Does it happen in the gateway? Or is it part of the NetServices.as and happens in the Flash-Client (in much the same way the XML.sendAndLoad(....) transforms a synchronous call to a asynchronous) . If it happens in the Client, is there any conceptual reason, that the very same mechanism schould not work with XML-RPC or SOAP? Shouldn't it be possible to build this with XML.sendAndLoad?


    Using XML-RPC/SOAP for Remoting instead of AMF would have had the obvious advantage of being more standards-compliant: You could have other clients than flash connect to the very same Webservice without any changes, and Flash could connect without the necessity to (buy&) install a gateway. Using SOAP allows you to debug the receiving site with tools of your choice: There exist numerous products out there that can intercept, parse and visualize SOAP-Messages,  and they usually integrate quite well with the development-enviroment of the receiving side.  The efforts, to reverse-enginner the AMF (thx to musicman)  clearly show a need to integrate with the server-side without a gateway. Apart from the price (which sould not be relevant to a site that really needs it, as there exits numerous other ways to connect to server-side applications without remoting) - the gateway introduces another element that has to be managed, integrated and understood (and another possible cause for errors): Which may prevent Organizations that already have a well established Webservices-Infrastructure from connecting to Flash-Clients...

    To sum it up: I really like the ease of use Remoting offers, but i still have not understood, why Remoting is not standards-based....




    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    Hi,

    all stuff inside flash player is asynchronous in nature ..., be it plain old loadvariables or a netconnection.call

    There are applications moving somewhat bigger datasets around, and here xml packaging certainly would  have an impact on speed and data size. I am just working on an app where I decided to avoid  remoting, because compiled movies create even better packing.

    Aside from technical issues, using a undisclosed protocol certainly gave MM server products an economic advantage as well

    Musicman

    drZoode

    • Server what's that
    • *
    • Posts: 6
      • View Profile
      • Email
    Hi All,

    I would like to add those links to the list of resources:

    http://www.flash-remoting.com/

    Flash Remoting with Java and .NET BLOG
    http://radio.weblogs.com/0113514/

    ASTranslator provides JavaBean-style mapping between Java objects in any J2EE application server and ActionScript objects in Flash MX when used with Macromedia Flash Remoting MX.
    http://carbonfive.sourceforge.net/astranslator/api/com/carbonfive/flash/package-summary.html

    NKConnect PHP Connector
    A connection system that allows remote method invocation on a PHP class/library located on a website
    Uses WDDX for data communication
    http://nuthing.com/nuthing/v7/

    Livedocs from MM:
    http://livedocs.macromedia.com/frdocs/Using_Flash_Remoting_MX/contents.htm

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    And of course - the newest link of all:

    http://amfphp.sourceforge.net

    Thanks for the links Dr. Zoode!
    Flash-DB