웹 서비스 입문 예

1798 단어 htmlxmlwebservice

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12">
	
<mx:Script>
    <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.utils.ArrayUtil;
      import mx.controls.Alert;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      private function onLoad(event:ResultEvent):void{
      	myWeatherReport.text = "";
        //Alert.show(event.result.toString(),"WebService Results");
        var weatherInfo:ArrayCollection = (event.result) as ArrayCollection;
        for(var i:int=0;i<weatherInfo.length;i++){
          myWeatherReport.text+=weatherInfo[i]+"
"; } } private function faultHandler(event:FaultEvent):void{ Alert.show(event.fault.toString(),'WebService Error'); } ]]> </mx:Script> <mx:WebService id="webService" wsdl="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl" showBusyCursor="true" result="onLoad(event)" fault="faultHandler(event)"/> <mx:TextInput id="cityname" text=" " x="90" y="36"/> <mx:Button label="Call WebService" click="webService.getWeatherbyCityName(cityname.text)" x="90" y="90"/> <mx:TextArea id="myWeatherReport" height="385" width="80%" editable="false" y="129" x="10"/> </mx:Application>

좋은 웹페이지 즐겨찾기