当前位置: 代码迷 >> Web前端 >> flex as中怎么使用webservice
  详细解决方案

flex as中怎么使用webservice

热度:147   发布时间:2012-09-22 21:54:54.0
flex as中如何使用webservice

/**
?? *方法一
?? */
??public function init():void
??{
???webservice = new WebService();
???webservice.useProxy=false;
???webservice.addEventListener(FaultEvent.FAULT,onFault);
???webservice.addEventListener(ResultEvent.RESULT,onResult);
???webservice.addEventListener(LoadEvent.LOAD,onLoad);
???webservice.wsdl = "http://192.168.80.83/webservice/PrivilegeService?WSDL";
???webservice.loadWSDL(webservice.wsdl);
???
???
???
??}
??
??private function onResult(event:ResultEvent):void
??{
???Alert.show("111");
???//this.txa1.text += event.message.body.toString()+"\n";
??}
??
??private function onFault(event:FaultEvent):void
??{
???Alert.show("333");
???//this.txa1.text += event.fault + "\n";
??}
??
??private function onLoad(event:LoadEvent):void
??{
???Alert.show("222");
???/* 调用方法需要传入二个参数,如果只传入一个,或者不传入,都会请求失败*/
???webservice.logon4Inner("aa","kkk");
??}

?

?

?/**
?? *方法二
?? */
??public function test():void{
???var ws:WebService= new WebService();
???ws.wsdl = "http://192.168.80.83/webservice/PrivilegeService?WSDL";
???ws.loadWSDL();
???var operation:AbstractOperation = ws.getOperation("logon4Inner");
???//为调用的方法添加监听器,回调函数由外部动态传入
???operation.addEventListener(ResultEvent.RESULT,this.callBackHandler);//增加处理函数
???
???operation.addEventListener(FaultEvent.FAULT,this.faultHandler);//增加处理函数
???var arr:Array = new Array();
???arr.push("china");
???//为调用的方法传参数,参数类型为Array
???operation.arguments = {userName:"aaa",pwd:"kkk"};
???//执行调用的方法
???operation.send(); ?
??}
??
??public function callBackHandler(event:ResultEvent):void{
???Alert.show("ggg");
??}
??
??public function faultHandler(event:FaultEvent):void{
???Alert.show("333");
??}

  相关解决方案