Creating a Named Proxy Service Destination

In this task, you will use a named Proxy Service instead of the default destination. It can be very useful to reference a name instead of a URL. A URL can change. If it does, you need to change the URL in all of your code. If you reference a named object, you would need to change the URL only in the configuration file.


In the proxy-config.xml file, just above the closing service tag, add a new <destination> tag with the id of categorizedProducts, as follows:

<destination > </destination> 

When you set up a destination in the proxy configuration file, you can reference the name of the URL instead of specifying the actual URL. In this case, you have set up a categorizedProducts destination. In your application, in the <mx:HTTPSerice> tag, you can reference the name of categorizedProducts.


Within the destination tag node, add a new <properties> tag and as a node of that, specify a URL property pointing to the URL that you are accessing the data from, as follows. Save the changes to the file.

<destination > <properties>   <url>   </url> </properties> </destination> 

From now on, you will reference the name categorizedProducts every time you need to make a call to this URL.


Return to the TfsDataServices.mxml file and locate the <mx:HTTPService> tag, and remove the url property from the tag. Add a destination attribute to the tag and specify the name of categorizedProducts, as follows:

<mx:HTTPService     destination="categorizedProducts"    resultFormat="e4x" useProxy="true"/> 


Save and run the application.

You should see that it works just like it did before.

Adobe Flex 2.Training from the Source
Adobe Flex 2: Training from the Source
ISBN: 032142316X
EAN: 2147483647
Year: 2006
Pages: 225 © 2008-2017.
If you may any questions please contact us: