views:

79

answers:

2

Hello, i' m using BlazeDs.

In services-config.xml we got following configuration of endPoint.

<channel-definition id="any-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>

Before compiling flash application i set up context-root as compilaction option.

bin\mxmlc  -context-root / -services "flex/services-config.xml" -optimize=true -o ..\..\bin\Messenger.swf Messenger.as

In my case this is "/"

And the problem is that messanger.swf is able to pull request if the web application is started as ROOT in tomcat webapps. I mean it can only be access by this url localhost:8080/. If i try to move webaplication to another folder - for example to localhost:8080/myApplication messenger.swf would not work properly sinse i have to change root_context as well.

So my question how to dinamicly determine context-root in run time, without hardcode it as option of compiler ? I want my .war application work properly regardless of it position in webapps folder(url).

Thank you

A: 

In this case I suggest to set the endpoint of your channels at runtime - you cannot change context-root variable during program execution.

Cornel Creanga
A: 

Use something like HTTPUtil.as from "Flex Pasta" to get the application URL at runtime and use the functions (getHostName, getContext, getPort) to calculate your servlet URL.

splash