Tuesday, 20 April 2010

Channels endpoints and destinations, AIR and Flex, courtesy of weborb and midnightcoders

Endpoint - this is the URL where AIR/Flex app sends remoting/messaging requests to

Channel - a concept encapsulating the endpoint. Also identifies classes managing the channel on both client and server sides

Destination - identifies a server-side class exposed by WebORB. Used by Flex/AIR client to target method invocations against the referenced class.

Channels are configured in WEB-INF/flex/services-config.xml (and
weborb-services-config.xml if present in your system). Every channel has the "endpoint" element. For example, you have the following
channel definition:

<channel-definition id="my-amf"
<endpoint uri="weborb.php"

Notice the following line:

<endpoint uri="weborb.php"

"weborb.php" here is actually a URL. The reason it does not look like a URL is because it is relative. If your Flex app is loaded from


then your application will be sending remoting requests to the following URL:


(This is the reason why WebORB for PHP requires that you put weborb.php into the same directory containing your SWF.)

So how does the client know what channel to use. The answer lies in remoting-config.xml. This is where all the destinations are defined.
Most of the destinations do not explicitly reference the channels. For those, there's a special declaration at the top that establishes the default channel:

<channel ref="my-amf"/>

As a result, when you create a RemoteObject to talk to GenericDestination, remoting requests will be sent to the endpoint defined in the my-amf channel.

Now, suppose you need to get AIR to talk to WebORB. Obviously the my-amf channel will not work for you since the endpoint is relative.
You can definitely change the endpoint to be an absolute URL and it will solve the problem. Alternatively, take a look at the channel with
the following ID:


Notice the endpoint URL for that channel is absolute. Now take a look at the GenericAIRDestination destination in remoting-config.xml. You will see it references the my-air-amf channel. As a result, if your
AIR application uses "GenericAIRDestination", your AIR client will talk to WebORB and send remoting requests to the endpoint URL from the
my-air-amf channel. It is important to adjust the URL to reflect the location of your WebORB instance.

Posted via email from fasanya's posterous

No comments: