flex中调用webservice的两种方法
来源:互联网 发布:北京java学费 编辑:程序博客网 时间:2024/06/09 14:53
1,用C#写好一个webservice,包含两个方法:
[WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public int GetSum(int a, int b) { int c = 0; c = a + b; return c; }
2,通过mxml配置,调用
<fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处 --><s:WebService id="myWebService" wsdl="http://localhost:4358/WebServicetest/WebService.asmx?wsdl"><s:operation name="GetSum" resultFormat="object" result="myresultTwo(event)"/><s:operation name="HelloWorld" resultFormat="object" result="myresultTwo(event)"/></s:WebService></fx:Declarations><s:Button id="myOne" x="184" y="177" width="131" height="47" label="MethodOne" click="myOne_clickHandler(event)"/><s:Button id="myTwo" x="393" y="177" width="131" height="47" label="MethodTwo" click="myTwo_clickHandler(event)"/>
<fx:Script><![CDATA[import mx.controls.Alert;import mx.events.FlexEvent;import mx.rpc.events.ResultEvent;import mx.rpc.soap.WebService;public function myresultOne(event:ResultEvent):void{Alert.show(event.result.toString());}public function myresultTwo(event:ResultEvent):void{Alert.show(event.result.toString());}protected function myOne_clickHandler(event:MouseEvent):void{// TODO Auto-generated method stubmyWebService.HelloWorld();}protected function myTwo_clickHandler(event:MouseEvent):void{// TODO Auto-generated method stubmyWebService.GetSum(7,9);}]]></fx:Script>
3,通过AS调用
protected function application1_creationCompleteHandler(event:FlexEvent):void{// TODO Auto-generated method stubvar myser:WebService=new WebService();myser.wsdl="http://localhost:4358/WebServicetest/WebService.asmx?wsdl";myser.loadWSDL();myser.getOperation("HelloWorld").addEventListener(ResultEvent.RESULT,myresultOne);myser.getOperation("HelloWorld").send();myser.getOperation("GetSum").addEventListener(ResultEvent.RESULT,myresultTwo);myser.getOperation("GetSum").send(2,3);}public function myresultOne(event:ResultEvent):void{Alert.show(event.result.toString());}public function myresultTwo(event:ResultEvent):void{Alert.show(event.result.toString());}
- flex中调用webservice的两种方法
- Powerbuilder调用Webservice的两种方法
- webservice客户端调用常用的两种方法
- 动态调用WebService的两种方法(多线程)
- 调用天气查询webservice服务的两种基本方法
- android 调用webservice(两种方法)
- Flex中自定义事件的两种方法
- java调用webservice用是axis还是xfire的,两种调用方法不同。
- java调用webservice用是axis还是xfire的,两种调用方法不同
- ajax 调用webservice的两种方式
- WebService的两种调用方式
- WebService调用的两种方式
- WebService的两种客户端调用方式
- webservice的两种调用方式
- WebService的两种客户端调用方式
- WebService的两种客户端调用方式
- Flex的WebService调用安全问题
- flex调用WebService的wsdl
- HDOJ 1261
- ORA-38500: USING CURRENT LOGFILE option not available without stand
- 基于jQuery的弹出框(背景同时灰掉)【原创】
- 把数组排成最小的数
- android adb问题整理解决:The connection to adb is down和ADB server didn't ACK * failed to start daemon
- flex中调用webservice的两种方法
- 第十二章 Java IO
- poj1251(prim)
- Delphi程序自删除的几种方法
- 苹果电脑MAC 在Finder里面显示隐藏文件方法
- Unicode编码下面char *或者char数组转CString
- 七个高效的文本编辑习惯(以Vim为例)
- Solr\Lucene优劣势分析
- hpux 11.31 superdome9000 IA mirror