<?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