Flex is designed to interact with several types of services that provide access to local and remote server-side logic. For example, a Flex application can connect to a web service that uses the Simple Object Access Protocol (SOAP), a Java object residing on the same application server as Flex using AMF, or an HTTP URL that returns XML. AMF is the protocol used in Flash Remoting MX. The MXML components that provide data access are called data service components. MXML includes the following types of data service components:
The following example shows an application that calls a web service that provides weather information, and displays the current temperature for a given ZIP code. The application binds the ZIP code that a user enters in a TextInput control to a web service input parameter. It binds the current temperature value contained in the web service result to a TextArea control.
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" ><!-- Define the web service connection(the specified WSDL URL is not functional). --><mx:WebService id="WeatherService" wsdl="/ws/WeatherService?wsdl"><!-- Bind the value of the ZIP code entered in the TextInput controlto the ZipCode parameter of the GetWeather operation. --><mx:operation name="GetWeather"> <mx:request> <ZipCode>{zip.text}</ZipCode> </mx:request> </mx:operation> </mx:WebService> <mx:Panel title="My Application" marginTop="10" marginBottom="10" marginLeft="10" marginRight="10" ><!-- Provide a ZIP code in a TextInput control. --><mx:TextInput id="zip" width="200" text="Zipcode please?"/><!-- Call the web service operation with a Button click. --><mx:Button width="60" label="Get Weather" click='WeatherService.GetWeather.send()'/><!-- Display the location for the specified ZIP code. --><mx:Label text="Location:"/> <mx:TextArea text="{WeatherService.GetWeather.result.Location}"/><!-- Display the current temperature for the specified ZIP code. --><mx:Label text="Temperature:"/> <mx:TextArea text="{WeatherService.GetWeather.result.CurrentTemp}"/> </mx:Panel> </mx:Application>
The following figure shows the application rendered in a web browser window:
For more information about using data services, see Managing Data in Flex in Developing Flex Applications.
Version 1.5
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000020.htm
Comments