Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 186065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:34:54+00:00 2026-05-11T15:34:54+00:00

I need a way of getting the active server address, port, and context during

  • 0

I need a way of getting the active server address, port, and context during runtime from my flex application. Since we are using ant for our build process, the server connection information is dynamically specified in our build properties file, and the {server.name}, {server.port} and {context.root} placeholders are used in the services-config.xml file instead the actual values.

We have some other Java servlets running on the same machine as our blazeDS server, and I’d like some way to programmatically determine the server endpoint information so I don’t need to hardcode the servlet URL’s into an XML file (which is what we are presently doing).

I have found that I can at least get the context root by adding the following to our main application MXML file:

<mx:Application ... >   <mx:HTTPService id='contextRoot' rootURL='@ContextRoot()'/> </mx:Application> 

However, I still need some way of fetching the server address and port, and if I specify the entire address by giving -context-root=http://myserver.com:8080/mycontext, then the flex application attempts to connect to http://localhost/http://myserver.com:8080/mycontext/messagebroker/amf, which is of course totally wrong. What is the proper way to specify the context root and server URL, and how can I retrieve them from our application?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:34:54+00:00Added an answer on May 11, 2026 at 3:34 pm

    We use an Application subclass that offers the following methods :

     /**   * The URI of the AMF channel endpoint. <br/>   * Default to #rootURI + #channelEndPointContext + #this.channelEndPointPathInfo   */  public function get channelEndPointURI() : String  {     return this.rootServerURI + ( this.channelEndPointContext ? this.channelEndPointContext : '' ) + this.channelEndPointPathInfo  }   /**   * The root URI (that is scheme + hierarchical part) of the server the application   * will connect to. <br/>   * If the application is executing locally, this is the #localServerRootURI. <br/>   * Else it is determined from the application #url. <br/>   */   public function get rootServerURI() : String  {       var result : String = ''       if ( this.url && ( this.url.indexOf('file:/') == -1 ) )       {            var uri : URI = new URI( this.url )            result = uri.scheme + '://' + uri.authority + ':' + uri.port       }       else       {            result = this.localServerRootURI       }        return result   } 

    This generic application supports the channelEndPointContext, channelEndPointPathInfo and localServerRootURI properties (typically ‘mycontext’ and ‘/messagebroker/amf/’ in your example, the local server root being used when the application is executed via Flex Builder, in such cases it has a file:// URL).
    The determination of the complete endpoint URI is then performed using either the localServerRootURI property or using the application url as our services are exposed by the very same server that serves the application’s SWF (which is, as far as I understand your case too).

    So, in your example, one would write :

     <SuperApplication ...> <!-- SuperApplication is the enhanced Application subclass -->     <mx:HTTPService id='myHTTPService' url='{this.channelEndPointURI}'/>  </SuperApplication> 

    Starting from here, one can also automatically determine the channelEndPointContext from the application URL instead of hardcoding it as shown in this example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there has to be a way: I need help getting any hot
I need a way to store application-level data (i.e. cross user sessions) in ASP.NET.
I need fastest way to convert files from latin1 to utf-8 in python. The
Is there any way of getting a key value from an NSDictionary based on
I need a way for getting all of the file handles of a given
Getting the active application is not a problem, I already have this implemented. What
I have a rather complicated (and very inefficient) way of getting utilisation from a
I need the correct way of getting latitude and longitude in Android programmatically. I
So I need a little help with understanding the best way of getting input
I need a way for a single variable to represent two kinds of objects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.