<services-config>And changed my project properties to add this line to the Flex Compiler page:
<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="http://localhost/amfphp/gateway.php"
class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
</services-config>
-services services-config.xmlBut I just came across this post which shows how to get around having to have an XML file by defining the channel at runtime.
So here is my simplified Flex code:
import mx.rpc.events.ResultEvent; |
You could also do the same in MXML:
<mx:ChannelSet id="channelSet">
<mx:channels>
<mx:AMFChannel uri="http://localhost/amfphp/gateway.php"/>
</mx:channels>
</mx:ChannelSet>
<mx:RemoteObject source="TestService" destination="amfphp"
channelSet="{channelSet}" id="remoteObject"
fault="trace('Fault: '+event.fault)"
result="trace('Result: '+event.result)"/>
And the corresponding PHP code (put the php file inside your webroot/amfphp/services directory):
<?php
?>
class TestService { |
So what are the benefits of this approach? Well, I'm not sure. In my case it was better because I have one logging class that does all the remoting, and is used by many different Flex applications. So instead of having to duplicate the services-config.xml file in every flex application this way I could define my endpoint url (http://localhost/amfphp/gateway.php) in one place.
Here is another site that is useful when getting started with amfphp:
