加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex 调用WebService

发布时间:2020-12-15 00:57:00 所属栏目:百科 来源:网络整理
导读:先看看Flex如何调用WebService。代码如下,调用的还是手机号码归属地查询,两个参数,一个手机号码,一个用户Id。 mx:WebService ? id = "WS" ? wsdl = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl" ? ? ? fault = "Alert.show(ev

先看看Flex如何调用WebService。代码如下,调用的还是手机号码归属地查询,两个参数,一个手机号码,一个用户Id。

 
 
  1. <mx:WebService?id="WS"?wsdl="http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl"? ?
  2. ?fault="Alert.show(event.fault.faultString),?'Error'"?>?
  3. ????????<mx:operation?name="getMobileCodeInfo"?resultFormat="object"??result="GetCourse(event)">?
  4. ????????????<mx:request>?
  5. ????????????????<mobileCode>{txtMobileNumber.text}</mobileCode>?
  6. ????????????????<userID>{txtUserId.text}</userID>?
  7. ????????????</mx:request>?
  8. ????????</mx:operation>?
  9. </mx:WebService>?

看看as是怎么写的,代码如下

 
 
  1. function?GetCourse(event:ResultEvent) ?
  2. ????????????{ ?
  3. ????????????????var?result:XML=new?XML(event.result.toString()); ?
  4. ????????????????if(result.Error!=null&&result.Error!="") ?
  5. ????????????????{ ?
  6. ????????????????????labInfo.text=result; ?
  7. ????????????????} ?
  8. ????????????????else{ ?
  9. ????????????????????labInfo.text="调用失败!"; ?
  10. ????????????????} ?
  11. ????????????}?

然后在某个按钮下写个click事件,<mx:Button x="137" y="67" label="调用WebService方法" click="showMsg();" width="141"/>对应的as代码如下

 
 
  1. function?showMsg() ?
  2. ????????{ ?
  3. ?????????????WS.getMobileCodeInfo(); ?
  4. ????????}?

看看运行效果,如下图

怎么样很简答吧。最后再看看如何弹出一个modal页面。

 
 
  1. <mx:TitleWindow?x="241"?y="163"?width="539"?height="260"?id="titleWindow"??layout="absolute"?title="学生信息详细信息"?visible="false">?
  2. ?????????????<mx:Button?x="452"?y="196"?label="关闭"?width="57"?click="closeHandler();"/>?
  3. ?????????????<mx:RichTextEditor?x="10"?y="10"?title="Title"?height="180"?width="499">?
  4. ?????????????</mx:RichTextEditor>?
  5. ?????</mx:TitleWindow>?

as代码如下

 
 
  1. import?mx.managers.PopUpManager; ?
  2. private?function?closeHandler():?void{????????????? ?
  3. ??????????????????PopUpManager.removePopUp(titleWindow);??? ?
  4. ??????????????????titleWindow.visible=false; ?
  5. ?????????????} ?
  6. ?????????????function?showPop() ?
  7. ?????????????{ ?
  8. ????????????????titleWindow.visible=true;?? ?
  9. ????????????????PopUpManager.addPopUp(titleWindow,this,true);?? ?
  10. ?????????????}?

运行效果如下

今天就写这些,祝大家龙年愉快。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读