Posts tagged services-config
Accessing services-config.xml values from Flex at runtime
Feb 11th
Recently I found this magic class in the Flex 3 SDK called ServerConfig. This class is great… What it allows you to do is access values that you defined in your services-config.xml file used to define the communication channels between Flex and your server.
Take the following services-config.xml file for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?xml version="1.0" encoding="UTF-8"?> <services-config> <services> <service id="amfphp-flashremoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage"> <destination id="amfphp"> <channels> <channel ref="my-amfphp"/> </channels> <properties> <source>*</source> </properties> </destination> </service> </services> <channels> <channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel"> <endpoint uri="gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/> </channel-definition> </channels> </services-config> |
As you can see, we’re setting the endpoint for our my-amfphp channel to gateway.php. What if you wanted to read that value into your Flex application? You could use the following code:
trace(ServerConfig.getChannel("my-amfphp").endpoint);
Check out the ServerConfig for more information!