Understanding the config-services file

A typical config-services file will look something similar to what is shown below. You would need to change the URI's to reflect your development or production machine, and I have had to remove a forward slash from my uri otherwise the formatting gets rather messed up.

config-services.xml

<?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='amfphpchannel'/>
          <channel ref='amfphpchannel2'/>
        </channels>
        <properties>
          <source>*</source>
        </properties>
      </destination>
    </service>
  </services>
<channels>    	   
    <channel-definition id='amfphpchannel' 
                        class='mx.messaging.channels.AMFChannel'>
      <endpoint uri='http:/localhost/amfphp-2.1/Amfphp/' 
                class='flex.messaging.endpoints.AMFEndpoint'/>
    </channel-definition>
 
    <channel-definition id='amfphpchannel2' 
                        class='mx.messaging.channels.AMFChannel'>
      <endpoint uri='http:/localhost/remote/Amfphp/' 
                class='flex.messaging.endpoints.AMFEndpoint'/>
    </channel-definition>
  </channels>
</services-config>

In the Declarations section of your Flex code you might have something like this:

<s:RemoteObject id="Bravo"    			
                source="Bravo" 			
                destination="amfphp">	
.
.
.
</s:RemoteObject>
  • id You normally refer to Flex components in AS via their id. You should already know this.
  • source This is the name of the PHP class that you'll be connecting with
  • destination This links in with your config-services.xml file. The value I specify here will match up with the id attribute of the destination tag. I can set up multiple destinations in the config-services file and this is useful if I need to connect to PHP objects on different servers

The destination tag has several sub-tags. The ref attribute of the channel tag points to the id attribute of the channel definition.

Okay so essentially what is happening here is this.

  • My Flex code has a RemoteObject which specifies a destination.
  • The value of of the destination attribute in the Flex code will match up with the id attribute of the destination tag in the config-services.xml file.
  • Inside the config-services.xml file, the destination tag tries the first channel -> following to the endpoint pointing to your amfPHP installation.
  • If something goes wrong with the first channel, then it will try the second channel you specified under the destination tag and so on.

Inside the config-services.xml file is a sub-tag for source

  <properties>
    <source>*</source>
  </properties>

This can be used to limit what PHP objects your Flex code can access via this destination. When I get a chance I'll add more information about this.

Tags: 

Comments

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.