6 Replies Latest reply on Jul 14, 2008 6:23 AM by Peter Farland

    How does a RemoteObject find its destination?

      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.
        • 1. Re: How does a RemoteObject find its destination?
          Mete Atamel Level 1
          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:

          • 2. Re: How does a RemoteObject find its destination?
            Alex Glosband Adobe Employee
            Hi Jason. Read the section in the developer documentation on Channels and endpoints and the section on Channel types.

            http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=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.

            • 3. Re: How does a RemoteObject find its destination?
              Level 1
              Ok, I think I understand. You are supposed to have BlazeDS compile the connection info into the SWF file. Is that right?
              • 4. Re: How does a RemoteObject find its destination?
                Level 1
                Ok folks, I am aware of the channel sets and end points. These are configured in BlazeDS, the server side of this client/server arrangement. Everybody fixates on this server config. I got that.

                But the client side is what I am fixated on.

                Let us view the flash player as a virtual machine. More importantly a virtual machine that is not the same virtual machine that BlazeDS is running in which is running in a J2EE app server somewhere in the universe (hopefully in the same domain) but elsewhere in that domain EXACT location unknown to the client VM. Unless somebody has told the CLIENT where BlazeDS (the server) is somehow or some where.

                From everybody's perspective there seems to be no separation in terms of Client/Server because all I get is its done on the server side config.

                The client is asking it's virtual machine to return a reference to a RemoteObject at destination="LahDeeDah" not LahDeeDah@somehost:someport:somepath or what ever syntax you would care to use. This implies that "LahDeeDah" is registered in some kind of hashing registry that knows something about where BlazeDS is located and that it even exists.

                How does the CLIENT swf program find this registry if I compile it in some IDE like Eclipse that is not aware that BlazeDS even exists somewhere? Remember, Channels and EndPoints are all configured on the server not in the CLIENT.

                You folks keep talking about how to configure the server side. I want to know what mechanism allows the client to get access to this server side configuration. Remember this conf.xml is on the server not in my IDE or in the src that creates my SWF file.

                As to an earlier post someone eluded to BlazeDS compiling the SWF file. No where in the docs did I see anything that said you MUST compile your src with BlazeDS and NOT some IDE like Flex Builder 3 which is what I am using.

                Did I miss this somewhere? Or was this info supposed to be handed down through divine revalation?

                Oh I give up! I'll just tear into the src and figure it out myself. It should be in the RemoteObject hierarchy.
                • 5. Re: How does a RemoteObject find its destination?
                  Mete Atamel Level 1
                  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.
                  • 6. Re: How does a RemoteObject find its destination?
                    Peter Farland Level 3
                    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


                    The source code is here: