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.

1.

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.

2.

Within the destination tag node, add a new <properties> tag and as a node of that, specify a URL property pointing to the http://www.flex2.net/categorizedProducts.xml URL that you are accessing the data from, as follows. Save the changes to the file.

<destination > <properties>   <url>     http://www.flex2.net/categorizedProducts.xml   </url> </properties> </destination> 


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

3.

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"/> 


4.

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

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net