import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.soap.LoadEvent;
import mx.rpc.soap.WebService;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
//private var str:String = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl";
private var str:String = "http://fy.webxml.com.cn/webservices/EnglishChinese.asmx?wsdl";
private var webService:WebService;
[Bindable]
public var ss:ArrayCollection;
private function onClick():void
{
//创建并实例化WebService示例,不过之前要先导入WebService类
webService = new WebService();
webService.wsdl = str;
webService.loadWSDL(str);
//事件侦听我就不说了,文档上都有
webService.addEventListener(LoadEvent.LOAD, onLoad);
webService.addEventListener(ResultEvent.RESULT, onResult);
webService.addEventListener(FaultEvent.FAULT, onFault);
//webService。GetWeatherByZipCode.addEventListener(ResultEvent.RESULT, onResult);
//webService。GetWeatherByZipCode.addEventListener(FaultEvent.FAULT, onFault);
}
private function onLoad(e:LoadEvent):void
{
//进行相关的操作
//webService.getWeatherbyCityName(txt.text.toString());
webService.TranslatorString(txt.text.toString());
}
private function onResult(e:ResultEvent):void
{
ss=(e.result) as ArrayCollection;
for(var i:int=0;i
myWeatherReport.text += ss[i]+"\n";
}
}
private function onFault(e:FaultEvent):void
{
trace(e.message);
Alert.show("错误:"+e.fault.faultString+"细节:"+e.fault.faultDetail,"错误");
}
]]>