数据交互之--WebService应用
System.security.allowInsecureDomain ("*");
System.security.allowDomain ("*");
this.createTextField ("txt", 5000, 10, 0, 530, 500);
arr_type = ["地区", "时间", "风向", "能见度", "天气", "最高温度", "最低温度", "相对湿度", "压强"];
import mx.services.WebService;
function getWeather () {
var ws:WebService = new WebService ("http://www.webservicex.net/globalweather.asmx?WSDL");
for (var i in ws) {
//trace(i+"="+ws[i])
}
cnt = 0;
cityName = "Guangzhou";
countryName = "China";
wsObj = ws.GetWeather (cityName, countryName);
wsObj.onResult = function (xml) {
txt.text = "";
//for(var i in this.myCall.log){trace(i+"="+this.myCall.log[i])}
str = xml.split ("\n").join ("").split ("\r").join ("");
weatherData = new XML (str);
weatherData.ignoreWhite = true;
data_Array = new Array ();
for (var i = 0; i < weatherData.firstChild.childNodes.length - 1; i++) {
//data_Array[i] = weatherData.firstChild.childNodes[i];
if (weatherData.firstChild.childNodes[i].firstChild != null) {
data_Array[i] = [];
//data_Array[i]=[];
data_Array[i][0] = String (weatherData.firstChild.childNodes[i].firstChild).split (" ");
//data_Array[i][1]=data_Array[i][0]
trace (data_Array[i][0]);
txt.text += arr_type[cnt] + ":" + weatherData.firstChild.childNodes[i].firstChild + newline;
cnt++;
}
}
};
wsObj.onFault = function (fault_I) {
trace (fault_I);
};
}
getWeather ();
txt.text = "获取数据中.....";
要想知道接口具体提供的方法可以直接
打开http://www.webservicex.net/globalweather.