Flex与.NET互操作(十四):FluorineFx的AMF(Action Message Format)协议通信2011-07-11 博客园 BeniaoAMF(Action Message Format)在开发Flash/Flex应用中使用频率是非常高的,相对普通的HTTP、WebService的SOAP等多种数据通信方式的效 率更高,有人曾经做过这方面的测试,详细可以访问:http://xinsync.xju.edu.cn/index.php/archives/2162。本文将结合FluorineFx来提供 通信服务接口,在客户端通过Flex来访问,简单的介绍下关于使用FluorineFx的AMF(Action Message Format)协议通信的用法。首先 建立一个FluorineFx服务库,并建立一个数据传输对象(DTO),为该对象添加[FluorineFx.TransferObject]表示该对象可以用作于 FluorineFx的数据传输对象,这个对象将会在本文后面用到,如下代码块:namespace FxDotNet.Services.DTO { [FluorineFx.TransferObject] public class Book { public int ID { get; set; } public string Name { get; set; } public string Author { get; set; } public double Price { get; set; }
public Book() { }
public Book(int id, string name, string author, double price) { this.ID = id; this.Name = name; this.Author = author; this.Price = price; } } }接下来就需要提供一个FluorineFx的远程服务(即标记有[RemotingService]的对象),通过该服务提供对外访问的方法 接口,如下代码块:namespace FxDotNet.Services { [RemotingService] public class DataServices { public DataServices() { }