Calling a simple web service from Flex using the WebService class
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.utils.ObjectUtil; private var startTime:int; private var endTime:int; private function button_click():void { webService.getMonths.send(); startTime = getTimer(); lbl.text = ""; } private function getMonths_result(evt:ResultEvent):void { textArea.text = ObjectUtil.toString(evt.result); calcTime(); } private function getMonths_fault(evt:FaultEvent):void { Alert.show(evt.type); calcTime(); } private function calcTime():void { endTime = getTimer(); lbl.text = "total time: " + (endTime - startTime) + "ms"; } ]]> </mx:Script> <mx:WebService id="webService" wsdl="http://www.flash-mx.com/ws/months.cfc?wsdl; <mx:operation name="getMonths" resultFormat="object" result="getMonths_result(event);" fault="getMonths_fault(event);" /> </mx:WebService> <mx:ApplicationControlBar dock="true"> <mx:Button id="button" label="get months from web service" click="button_click();" /> <mx:Spacer width="100%" /> <mx:Label id="lbl" /> </mx:ApplicationControlBar> <mx:TextArea id="textArea" editable="false" width="100%" height="100%" /> </mx:Application> |
11:49 AM
|
Labels:
Flex Components Downloads,
Flex Controls Samples
|
This entry was posted on 11:49 AM
and is filed under
Flex Components Downloads
,
Flex Controls Samples
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment