Setting up access to Flex Remote Objects without access to WEB-INF directory
When creating a project in Flex Builder if you select the application server type as J2EE you need to have access to the WEB-INF flex folder of the server and the services-config.xml configuration file of the remote server. So what do you do if you don't have access to the WEB-INF flex folder?
First create a normal Flex project (ie leave the application server type as 'none').
Next add these options to the addition compiler arguments in the flex compiler page of your project properties.
Where "
Next create a config directory and create this services-config.xml file:
2<services-config>
3 <services>
4 <service-include file-path="remoting-config.xml" />
5 <!-- may need a proxy config for deployment -->
6 </services>
7
8 <channels>
9 <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
10 <!-- server.name and server.port are replaced at runtime by server swf is loaded from -->
11 <!-- <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> -->
12 <endpoint url="http://<server name>:<server port>/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
13 </channel-definition>
14 </channels>
15
16</services-config>
Where
And lastly create a remoting-config.xml file:
2<service id="remoting-service" class="flex.messaging.services.RemotingService">
3
4 <adapters>
5 <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true" />
6 </adapters>
7
8 <default-channels>
9 <channel ref="my-amf" />
10 </default-channels>
11
12 <destination id="<my destination>">
13 <properties>
14 <source><path to remote object></source>
15 </properties>
16 </destination>
17</service>
Where
There are a couple of issues with defining the server this way:
1. If you change the configuration file the Flex project will not compile automatically.
2. There is no way to set the server.name and server.port via compiler arguments so the server name and port need to be hard coded in the the configuration file. If you have testing and production servers you must remember to change these details in the configuration file and recompile (or have it changed automatically as part of your build process).
You apply this method to an existing an existing Flex project by changing the .flexProperties file to be like this
2<flexProperties flexServerType="0" toolCompile="true" useServerFlexSDK="false" version="1"/>
and following the steps above.