BTA Flexing

My passion RIAs…………..Shardul Singh Bartwal

Encounter with services-config.xml in Adobe Flex

Posted by Shardul Singh Bartwal on October 8, 2008

 services-config file is used by us for connection to the server side code.One important thing which should be noticed here is that this file is used at compile time (as we also includes {-services “services-config.xml”} under compiler settings). If you are using this file then there will be a block like below.


     <channel-definition id=”my-amfphp” class=”mx.messaging.channels.AMFChannel”>

           <endpoint uri=”http://IP of ur backend server/Project Name/amfphp/gateway.php”




The important thing here is ‘endpoint’ tag,Which have a uri field.This uri field is used to give

the path of backend server.But I will suggest not to put the this uri field here.As you know why?

Because if u will give this ip related information here then you can never change it because it will

be included in the build.So what we require to do when using this file,we should simply remove ‘uri’

from here and write it with your each and every remote object.And there you can get it from some

external xml,or by any other medium.


So the above block in services-config.xml should look like this only.



<channel-definition id=”my-amfphp” class=”mx.messaging.channels.AMFChannel”>

<endpoint class=”flex.messaging.endpoints.AMFEndpoint”/>






Hope you will enjoy it…………………..



4 Responses to “Encounter with services-config.xml in Adobe Flex”

  1. “uri field is used to give the path of backend server.But I will suggest not to put the this uri field here”
    No, you shouldn’t hardcode the name or IP of the server, instead you should use the {} token – there are others given as examples in the default file.
    That is, unless your application is talking to an end point that is on a different server to the deployed one, in which case it really should change so infrequently that sticking the host name in is fine.

  2. Shardul singh Bartwal said

    Hi Tom,
    Thanks for commenting.
    You are absolutely right.I m not saying to put uri hard code with Remote object.I have mantioned that we have to pick this from somewhere outside.That we can get from some other xml.
    Like we can get that path from xml in to any class’s static variabe and then we can pass it in to uri.So latter on we can change the path in xml.Which will be reflected with our application.


  3. Mick Powell said

    Thanks Shardul,

    Cool post which saved me a lot of time. One thing it might be worth mentioning is the endpoint property on the remoteobject where the uri value has to go, and maybe show that being set from a value in an xml configuration file as you suggest.

    Many examples on the internet show the uri compiled into the services-config.xml file, and for code re-usability its an absolute must to get it out of there. Its a very important point to make and well done for doing so.

  4. Classic said

    can you plz put example to access uri with external file

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: