Cairngorm学习——使用WebService和HTTPService服务

by 蛐蛐 29. August 2008 15:17
参考:http://nwebb.co.uk/blog/?p=118

一、使用WebService
 
在Services.mxml中你须建立WebService服务,如:
 
1 <mx:WebService id="自定义ID" wsdl="{您的wsdl地址}" useProxy="false">
2 <mx:operation name="wsdl中的方法名"/>
3 </mx:WebService>

 
1<mx:webservice>
2 id="自定义ID"
3 wsdl="{您的wsdl地址}"
4 useProxy="false">
5 <mx:operation concurrency="multiple" name="wsdl中的方法名1" />
6 <mx:operation concurrency="multiple" name="wsdl中的方法名2" />
7</mx:webservice>
 
其实和平常定义的WebService没有两样,只是不须添加<mx:request>标签。
 
在AS3中的调用方法,如:
 
1package cn.soave.flexblog.business
2{
3 import com.adobe.cairngorm.business.ServiceLocator;
4
5 import mx.rpc.IResponder;
6
7 public class BlogDelegate
8 {
9 private var service:Object;
10 private var responder:IResponder
11
12 public function BlogDelegate(responder:IResponder)
13 {
14 this.responder = responder;
15 }

16
17 /*获取最新更新的博客文章列表*/
18 public function getLastBlogList(参数1,参数2):void
19 {
20 this.service = ServiceLocator.getInstance().getWebService("自定义的WebService标签ID");
21 var call:AsyncToken= this.service.WebService中的方法名(参数1,参数2);
22 call.addResponder(this.responder);
23 }

24
25 }

26}

二、使用HTTPService

 在Services.mxml中你须建立HTTPService服务,如:
 
1<mx:httpservice id="自定义标识ID" url="您的网页URL" showBusyCursor="true" method="POST" resultFormat="text"/>
 
 在AS3中调用的方法,如:
 
1package cn.soave.flexblog.business
2{
3 import com.adobe.cairngorm.business.ServiceLocator;
4
5 import mx.rpc.AsyncToken;
6 import mx.rpc.IResponder;
7
8 public class BlogDelegate
9 {
10 private var service:Object;
11 private var responder:IResponder
12
13 public function BlogDelegate(responder:IResponder)
14 {
15 this.responder = responder;
16 }

17
18 public function getUser():void
19 {
20 this.service = ServiceLocator.getInstance().getHTTPService("自定义的HTTPService标签ID");
21 var call:AsyncToken = this.service.send({参数1,参数2,...});
22 call.addResponder(this.responder);
23 }

24
25 }

26}

Currently rated 4.0 by 3 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Flex/AIR

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

RecentComments

Comment RSS