0 Replies Latest reply on Oct 4, 2011 12:06 AM by IshanTrikha1

    Any APIs in Flex for figuring out server details at runtime ?




      I have a flex application using BlazeDS for connectivity with java. As those who have used it would know, BlazeDS requires me to sort of hardcode the endpoint url for any given channel in the services-config.xml. This services-config.xml is also given as a compiler argument to flex application.

      for e.g.


      <channel-definition id="my-amf-try" class="mx.messaging.channels.AMFChannel">

                  <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"




      Channels like these are then used by remote objects for invoking back end java methods. Here, though {server.name} and {server.port} are loaded at run time, {context.root} is loaded at compile time. Moreover at times, there may be no {server.port} in prod environment. My requirement is to find some way by which the application can dynamically create the channel for any remote object. To further elaborate, I need to do these two steps:

      1) to figure out the server where the swf is installed at run time and obtain details like [b]protocol, server:port[/b] etc.

      2) to create a channel dynamically using the above details.

      Now I have an idea about the second step - How to create a channel and assign it to a remote object. This is what I think can be done:


      var amfEndpoint:String =  getEndPointUrlDynamically(); // the code for this I need to figure out.

                  if (amfEndpoint == "")


                      Alert.show("amf channel is not configured", "Error");




                     amfchannelSet = new ChannelSet();

                     var channel:AMFChannel = new AMFChannel("my-amf-test", amfEndpoint);


                     firstobject.channelSet = amfchannelSet; // firstobject is bound to this channel at runtime.




      With this approach, services.config.xml is as good as absent. Because as far as the channel aspect of it is concerned, we are setting the details at runtime. I cannot find any APIs in flex that will help me give the details of the server where the swf is installed. Something like this.getServer() etc. I know this might seem a strange requirement to some but that is what I have to do. My hint (a hint also means that this is "exaclty" how the boss wants it to be done- no other way !) is to find the APIs in flex that I just mentioned

      Please give any suggestions if anyone has any knowledge about this.