flex webservice获取城市的天气情况
2012-04-16 16:55
417 查看
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Style> global{ fontSize:12pt; } </mx:Style> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; //引入远程调用的事件处理 //向WebService发送请求 private function sendCount():void { ws.getWeather.send(); } //显示结果的处理函数 private function showResult(rs:ResultEvent):void { //得到返回的结果 var rsStr:ArrayCollection=ArrayCollection(rs.result); var info:String = ""; for(var i:int=0;i<rsStr.length;i++) { info+=rsStr[i]+"\n"; } Alert.show(info); cityInfoText.text=rsStr[0]; } private function faultResult(faultmessage:FaultEvent):void { var faultStr:String=new String(faultmessage.message); Alert.show(faultStr, "WebService访问错误"); } private function go():void { navigateToURL(new URLRequest("http://www.webxml.com.cn/"), "_blank"); } //清空查询信息 private function clearText():void { cityCode.text=null; userid.text=null; } ]]> </mx:Script> <!-- 引入WebService标签,设定wsdl。不使用代理名称--> <!--此 WebService由网站:http://www.webxml.com.cn/提供。该网站内还有其它免费web服务 --> <mx:WebService id="ws" wsdl="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" useProxy="false" showBusyCursor="true" result="showResult(event)" fault="faultResult(event)"> <mx:operation name="getWeather" resultFormat="object"> <mx:request> <theCityCode>{cityCode.text}</theCityCode> <theUserID>{userid.text}</theUserID> </mx:request> </mx:operation> </mx:WebService> <mx:Panel x="296" y="107" width="364" height="277" layout="absolute" title="城市天气查询" horizontalAlign="center" verticalAlign="middle"> <mx:TextInput x="127" y="33" id="cityCode"/> <mx:Button x="114" y="182" label="查询" click="sendCount()"/> <mx:Text x="35" y="154" text="" width="299" id="cityInfoText"/> <mx:Button x="174" y="182" label="清除" id="clear" click="clearText()"/> <mx:TextInput x="127" y="78" id="userid"/> <mx:Label x="35" y="35" text="城市ID/城市名"/> <mx:Label x="35" y="80" text="UserId"/> </mx:Panel> <mx:Text width="321" height="50" x="318" y="37"> <mx:htmlText> <![CDATA[ <a href="http://blog.163.com/liwei3324@126/" target=" _blank">如有不懂的地方,欢迎访问我的博客。点击我</a> ]]> </mx:htmlText> </mx:Text> <mx:Label x="135" y="403" text="此WebService是由网站http://www.webxml.com.cn/提供" fontSize="22" fontWeight="bold" fontStyle="italic"/> <mx:LinkButton x="404" y="458" label="走,去看看!>>" color="#1510EC" click="go()"/> </mx:Application>
相关文章推荐
- Flex webService调用天气预告服务数据
- ajax获取当前城市天气情况
- 在安卓中获取一个城市的天气情况
- Android使用"中国天气网"API数据通过城市名称获取天气情况
- python获取城市天气情况案例
- Soap请求获取指定城市的天气情况并在天地图API Map中显示
- Android使用"中国天气网"API数据通过城市名称获取天气情况
- python获取城市天气情况案例
- webservice 异步获取天气,省市联动 。JSP+Ajax+Servlet+WebService
- android webservice获取城市天气情况
- 想在自己的android应用中获得当天的天气情况,这该怎么做呢?不用担心。中国国家气象局提供了获取所在城市天气预报信息接口。通过这个接口,我们就可以获取天气信息了。
- android webservice获取城市天气情况
- WPF实例:通过WebServices获取城市的天气情况
- java调用webservice获取指定城市天气情况的例子
- android webservice获取城市天气情况
- android webservice获取城市天气情况
- python 学习笔记 12 -- 写一个脚本获取城市天气信息
- flex&webservice
- C# 解析百度天气数据,Rss解析百度新闻以及根据IP获取所在城市
- 基于WebService+Flex的B/S系统架构