Мы используем подкласс Application, который предлагает следующие методы:
/**
* 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
}
Это универсальное приложение поддерживает свойства channelEndPointContext
, channelEndPointPathInfo
и localServerRootURI
(как правило, "mycontext" и "/ messagebroker / amf /" в вашем примере, корень локального сервера используется, когда приложение выполняется через Flex Builder, в таких случаях он имеет file://
URL).
Определение полного URI конечной точки затем выполняется с использованием либо свойства localServerRootURI
, либо с использованием приложения url
, поскольку наши сервисы предоставляются тем же сервером, который обслуживает SWF приложения (что, насколько я понимаю, ваш случай тоже).
Итак, в вашем примере можно написать:
<SuperApplication ...> <!-- SuperApplication is the enhanced Application subclass -->
<mx:HTTPService id="myHTTPService" url="{this.channelEndPointURI}"/>
</SuperApplication>
Начиная с этого момента, вы также можете автоматически определять channelEndPointContext
из URL-адреса приложения вместо его жесткого кодирования, как показано в этом примере.