Flex调用webservice

本文介绍如何使用Flex语言调用WebService,通过具体代码示例展示了设置WebService接口、定义操作及请求过程。适用于希望了解Flex中WebService交互实现方式的开发者。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:WebService id="HelloWorld" 
         wsdl="http://localhost:8080/HelloWorld/services/HelloWorldService?WSDL"
         useProxy="false">
        <mx:operation name="example">
            <mx:request>
                <in0>{input.text}</in0>
            </mx:request>
        </mx:operation>
    </mx:WebService>
    <mx:Panel id="panel" x="10" y="10" width="475" height="400" layout="absolute" title="Most Popular Posts">
    
        <mx:TextInput x="194" y="20" id="input"/>
        <mx:Button x="169.5" y="60" label="连接WebService" id="btn" click="HelloWorld.example.send()"/>
        <mx:Text x="169.5" y="106" text="{HelloWorld.example.lastResult}" id="txt"/>
                
    </mx:Panel>
   </mx:Application> 

<!--调用webservice的语句-->
    <mx:WebService id="Users" wsdl="http://localhost/Users/Users.asmx?wsdl"
    showBusyCursor="true" useProxy="false">
        <!--调用方法-->
        <mx:operation name="方法名" result="resultFlex(event)">
        <!--这里对应WEBSERVICE的方法名,注意必须和WEBSERVICE的方法同名-->
            <mx:request> <!--接收方法参数-->
                <Users > <!--传入你要的参数名称,这里的参数必须和WEBSERVICE里的方法参数同名-->
                {要传的参数}
                </Users >
            </mx:request>
        </mx:operation>
    </mx:WebService>
    <mx:Script>
    <![CDATA[       
    private function resultFlexWeather(event:ResultEvent):void{
    //这里是你在调用webSerivce后想做的事情
    }
    ]]>
.....
注意:你想要激活webService的时候请使用:Users.[webmethode].send()

参考:
http://topic.youkuaiyun.com/u/20080825/00/890546e9-db14-45fc-b660-3fcf9e10125e.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值