zoukankan      html  css  js  c++  java
  • Flex beta2+XFire开发实例 (三)

    最后一章

    三、编写调用实例


    1、设计界面


    我是做得比较简单,有一个TextArea用来显示调用结果输出,一个Button用来调用服务的login方法。

    2、代码编写

    Webs1.mxml

    <?xml version="1.0" encoding="utf-8"?>

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init(event);">

        <mx:Button x="207" y="192" label="getUserInfo" click="getUserInfo(event);"/>

        <mx:TextArea x="80" y="57" width="223" height="127" id="out"/>

        <mx:Script>

           <![CDATA[

               import symis.business.service.UserManagerService;

               import symis.business.service.User;

               import mx.rpc.events.ResultEvent;

               import mx.rpc.AsyncToken;

               privatevar userManagerService:UserManagerService;

              

               privatefunction init(e:Event):void{

                  userManagerService = new UserManagerService();

               }

               privatefunction getUserInfo(e:Event):void{

                  var result:AsyncToken =null;

                  if(userManagerService!=null)   

                      result =userManagerService.login(100,"hello");

                  if(result!=null)

                   result.addEventListener("result",function(e:ResultEvent):void{

                      var user:User = e.result as User;

                      out.text = "User Name:="+user.name+""n";

                      out.text +="age :="+user.age;

                  });

               }

           ]]>

        </mx:Script>

    </mx:Application>

    3、运行客户端


    a)       初始化webservice

    privatefunction init(e:Event):void{

                  userManagerService = new UserManagerService();

               }


    b)       调用webservice方法

    privatefunction getUserInfo(e:Event):void{

                  var result:AsyncToken =null;

                  if(userManagerService!=null)   

                      result =userManagerService.login(100,"hello");

                  if(result!=null)

                   result.addEventListener("result",function(e:ResultEvent):void{

                      var user:User = e.result as User;

                      out.text = "User Name:="+user.name+""n";

                      out.text +="age :="+user.age;

                  });

               }


    四、结束语
    抽空写了一些WebService资料,周六晚上也没有好好休息,好长时间没有陪儿子好好玩了,明天还得要开会,希望这些心得能对朋友有些帮助。


  • 相关阅读:
    bat入门--第一个bat文件
    Egret的Shape
    Less Time, More profit 最大权闭合子图(最大流最小割)
    Mayor's posters POJ
    Stars POJ
    Snacks
    有趣的数列 卡特兰数
    Devu and Flowers lucas定理+容斥原理
    整数分解为2的幂 数学
    易碎的鸟蛋 概率DP
  • 原文地址:https://www.cnblogs.com/jssy/p/931773.html
Copyright © 2011-2022 走看看