views:

47

answers:

2

I would like to use different service definitions in a Flex app depending on whether I'm running on:

  • My local developer machine
  • The test tier
  • The QA tier
  • The production tier

My services are all AMFPHP remote objects, living on different hosts and at different locations depending on which tier I'm on. How can I have my flex app choose the 'correct' tier at runtime to connect to?

A: 

Are the definitions actually different, or are they only at different locations on the network?

If they're just different locations on the network, I'd suggest adding some sort of (XML) Configuration file to your Flex app that let you specify the URL of the service endpoint.

If they actually have different service definitions, I'd question why you'd want to develop against something that doesn't match what you'll be running in production.

UPDATE

Here's a link to a good quick reference on how to get started loading an XML document using AS3:

Pixelfumes Flash Blog: Easy XML Parsing using AS3

You can use those techniques to load an XML document containing your URL configurations.

Justin Niessner
The services are the same, but they're at different locations. What I want to know is how to create that '(XML) Configuration file' in such a way as to allow a different one to be in place on each tier. Ideally, without a recompile of the application.
Chris R
I should clarify; the services may differ between tiers because I'm developing the services in parallel; so, the services on test may have changes to them that are not yet in place on QA/production (for what should be obvious reasons)
Chris R
Right. I know how to load XML. I do NOT, however, know how to have several different versions of that XML definition, defined to point to four different target environments, depending on which tier the application is running in.
Chris R
A: 

Spring ActionScript allows you to do this by externalizing service endpoint configuration in xml and properties files. I blogged about this here.

Basically, you define your services/remote objects in an external xml file and use placeholders for the properties which you define in a properties file. You don't need to do any parsing yourself since Spring ActionScript does that for you.

Christophe Herreman