flex 和webService 通讯
来源:互联网 发布:ios软件安装目录 编辑:程序博客网 时间:2024/04/29 15:03
在flex中和webservice是很简单,使用Webservice类就好了。
先说一下他的使用呀
web=new WebService();
//这是一个webservice的地址;
web.wsdl = "http://www.webservicex.net/globalweather.asmx?wsdl";
web.loadWSDL();
这样就已经连接上了.
想监控连接是否成功可以注册LoadEvent.LOAD事件
web.addEventListener(LoadEvent.LOAD,OnLoad);
下来就可以调用webservice的接口了,激动的时刻来了,如果接口有返回值的话,要先监听一下结果
web.GetCitiesByCountry.addEventListener(ResultEvent.RESULT, OnGetCity);
web.GetCitiesByCountry("china");
private function OnGetCity(event:ResultEvent ):void{
var xml:XML=new XML(event.result);
}
这样就可以了,很简单吧.
下面给大家一个例子,天气预报的
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.rpc.soap.LoadEvent;
import mx.rpc.soap.WebService;
import mx.rpc.events.ResultEvent;
[Bindable]
private var city:Array=new Array();
private var web:WebService;
private function init():void{
web=new WebService();
web.wsdl = "http://www.webservicex.net/globalweather.asmx?wsdl";
web.addEventListener(LoadEvent.LOAD,OnLoad);
web.loadWSDL();
web.GetCitiesByCountry.addEventListener(ResultEvent.RESULT, OnGetCity);
web.GetCitiesByCountry("china");
web.GetWeather.addEventListener(ResultEvent.RESULT,OnGetWeather);
}
private function OnLoad(event:Event):void{
pnlWeather.title+="------ webservice connected ... "
}
private function OnGetCity(event:ResultEvent ):void{
var xml:XML=new XML(event.result);
for each ( var name:XML in xml..City ) {
city.push(name);
}
cmbCity.selectedIndex=0;
}
private function OnGetWeather(event:ResultEvent ):void{
txtRWeather.text="";
var xml:XML=new XML(event.result);
var xmlList:XMLList=xml.children();
for (var i:int =0;i<xmlList.length();i++){
txtRWeather.text+= xmlList[i].toXMLString()+"/n";
}
}
private function OnClick():void{
web.GetWeather(cmbCity.selectedLabel,"china");
}
]]>
</mx:Script>
<mx:Panel title="Weather" height="262" width="421" layout="absolute" id="pnlWeather">
<mx:Label text="city:" x="74" y="24"/>
<mx:ComboBox x="130" y="24" width="106" id="cmbCity" dataProvider="{city}"></mx:ComboBox>
<mx:Button x="258" y="24" label="提交" click="OnClick()"/>
<mx:TextArea x="130" y="54" width="261" height="156" id="txtRWeather"/>
<mx:Label x="74" y="53" text="weather"/>
</mx:Panel>
</mx:Application>
- flex 和webService 通讯
- flex 和webService 通讯
- 使用Httpservice和Webservice来和Flex进行通讯
- Flex与asp.net的WebService通讯
- Flex与asp.net的WebService通讯
- pb和webservice的通讯
- Flex WebService 和 Axis2全过程
- PHP和java通讯 WebService+JavaBridge
- Flex与服务器交互之三(使用WebService组件同服务器WebService通讯)
- Flex与服务器交互之三(使用WebService组件同服务器WebService通讯)
- FLex webservice
- Flex WebService
- flex+webservice
- flex在线mp3播放器(一)通过webservice 与服务器通讯,获取mp3列表
- flex actionscript 和 javascript 通讯(3) 整合例子
- flex的Socket通讯沙箱和安全策略问题
- flex 模块通讯
- Webfocus Flex 之间通讯
- Remove Nth Node From End of List
- HTML5学习
- myeclipse 调试技巧
- 读写随机访问文件
- centos6.4配置ip dns
- flex 和webService 通讯
- C++11 理解 (二十三) 之 通用智能指针
- MyXls导出Excel的各种设置
- [Oracle] Data Guard 系列(5) - 创建逻辑备库
- 【解决Win7&Win8摄像头使用时有波纹闪烁问题】
- JS-JSON-UI
- Uninstall Microsoft Security Essentials with WindowsUninstaller.Org Removal Tips
- 云计算管理三大利器:Nagios、Ganglia和Splunk
- 适配器模式