Flex访问C#Webservice

来源:互联网 发布:html5 商城源码下载 编辑:程序博客网 时间:2024/04/29 17:01
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:s="library://ns.adobe.com/flex/spark"layout="absolute" minWidth="955" minHeight="600"><mx:TitleWindow width="1920" height="1080" layout="absolute" id="winMain" title="myfirst flx XX!" fontSize="12" borderColor="#1A212A"><mx:Label x="10" y="23" text="myfirstFlexprogram!" id="labstr" fontSize="12" width="210" height="20"/><mx:TextInput x="10" y="51" width="210" height="20" fontSize="12" id="txtname"/><mx:Button x="10" y="93" label="测试webservice" click="button1_clickHandler(event)" fontSize="12"/><mx:Button x="10" y="120" label="测试函数" click="showMSG(txtname.text)" fontSize="12"/></mx:TitleWindow><mx:Script><![CDATA[import mx.controls.Alert;import mx.rpc.events.FaultEvent;import mx.rpc.events.ResultEvent;protected function button1_clickHandler(event:MouseEvent):void{Alert.show("调用webservice!","提示"); fff.HelloWorld(txtname.text);}protected function button2_clickHandler(event:MouseEvent):void{Alert.show("调用函数测试","提示");}private function showMSG(strname:String):void{Alert.show(strname+",函数调用!","提示");}protected function operation2_resultHandler(event:ResultEvent):void{// TODO Auto-generated method stublabstr.text=event.result as String;//显示返回的值}]]></mx:Script><mx:WebService id="fff"   showBusyCursor="true"   wsdl="http://localhost:2222/TestWebservice.asmx?wsdl"   fault="Alert.show(event.fault.faultString,'Error')"><mx:operation name="HelloWorld" resultFormat="object" result="operation2_resultHandler(event)"/></mx:WebService></mx:Application>

0 0
原创粉丝点击