Skip navigation
Currently Being Moderated

How does a RemoteObject find its destination?

Jul 11, 2008 11:22 AM

I am new to Flex. I am a long time Java/C++/C developer so my head won't explode if we get technical.

I am trying to figure out how a RemoteObject finds it's destination with just a simple reference as "SomeDestId" configured on BlazeDS the app server.

From the client side I am used to getting a reference to some Registry like JNDI or whatever by stating which host and port to use or a URI or something more absolute. I am aware that the flash player has a sandbox so we can dispense with the host, we know what it has to be. But my question is. How does the swf file or the context of the flex app know where my BlazeDS is rooted in my J2EE app server if I don't tell it?

What am I missing? I have looked at the example code and have read the developer pdf but nobody talks about this.

Does BlazeDS start listing on a well known port other than the application server's port?

If not how is my flex program supposed to know what port BlazeDS is on?

Anyone know how this automagic works? Because I can't find it in the docs.

Does my SWF file need to be deployed from within the BlazeDS deployment if so I have missed where in the documentation this is stated.
  • Currently Being Moderated
    Jul 11, 2008 11:44 AM   in reply to (Jason_A._Adams)
    When you configure BlazeDS, you define endpoints (in services-config.xml) where you indicate which url the SWF needs to use to contact BlazeDS. Then you usually compile the MXML into SWF using the services-config.xml. As this point, SWF knows what URL to use contact the server.

    The new LCDS 2.6 (which is a superset of BlazeDS) documentation has information on this: d_apps_4.html
    Mark as:
  • Currently Being Moderated
    Jul 11, 2008 12:19 PM   in reply to (Jason_A._Adams)
    Hi Jason. Read the section in the developer documentation on Channels and endpoints and the section on Channel types. =messaging_framework_2.html

    The information needed for your flex program to talk to the BlazeDS server is contained in a ChannelSet. A ChannelSet can contain one or more Channels. When you make a RemoteObject call to the server, your flex application will try to make the request using the first Channel in the ChannelSet that is associated with the RemoteObject. If that Channel doesn't work for some reason, the next Channel in the ChannelSet will be tried and so on, until all the available Channels have been exhausted.

    Requests to the BlazeDS server are handled by a servlet so no port other than the application server's port is used. The information needed by the client to communicate with the server is compiled into the swf. In BlazeDS the information is contained in the services-config.xml file and related files referenced from within services-config.xml. The mxml compiler has a -services flag that is used to point to the services-config.xml file. The BlazeDS server uses this same file at runtime.

    No, your swf doesn't need to be deployed from the within the BlazeDS deployment but there are some security restrictions imposed by the FlashPlayer. If your flex application makes a request to a domain other than the domain from which the flex application was loaded from there are some things you need to do to allow the request to go through. Do a google search on "Flex Cross Domain" if you run into this problem and you will find plenty of information to help you.

    Hope that helps.

    Mark as:
  • Currently Being Moderated
    Jul 14, 2008 4:36 AM   in reply to (Jason_A._Adams)
    Jason, please reread my post (about compiling MXML with services-config.xml) and actually take a look at the LCDS documentation link I provided. There're two sections "Using Flex Builder to compile client-side code" and "Using mxmlc to compile client-side code". If you read those, you'll see that it has all the info you need and it's not divine revelation at all.
    Mark as:
  • Currently Being Moderated
    Jul 14, 2008 6:23 AM   in reply to (Jason_A._Adams)
    Essentially the key command line switches to focus on are -services
    which is used to point the compiler at your
    /WEB-INF/flex/services-config.xml file, and -context-root which is used
    to specify the WAR context path that serves as the root of your web
    application (as this cannot be reliably determined by the player at
    runtime). The context-root value is used to replace {context.root}
    tokens in your channel endpoints at compile time.

    So _how_ does the compiler achieve the magic for the -services switch?
    mxmlc uses a helper class, flex.messaging.config.ServicesDependencies
    from /lib/flex-messaging-common.jar (a BlazeDS JAR that is shared with
    the Flex SDK) to parse a subset of your services-config.xml file and
    generates some ActionScript code to populate the static "xml" property
    on the mx.messaging.config.ServerConfig class and hence is compiled into
    your SWF. This config information is used at runtime to construct the
    relevant mx.messaging.ChannelSet for your destination (see the
    method). fi

    The source code is here: me

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)