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.