The AMF (Action message Format) is used very frequently in the development of Flash/flex applications, and is more efficient than ordinary HTTP, WebService soap and many other data communications, and has been tested in this regard, Detailed access to: http://xinsync.xju.edu.cn/index.php/archives/2162. This article will combine FLUORINEFX to provide communication service interface, in the client through flex to access, a simple introduction of the use of FluorineFX AMF (Action message Format) protocol communication usage.
First, create a FLUORINEFX service library and create a data transfer object (DTO) that adds [Fluorinefx.transferobject] to the object that can be used as a data transfer object for the FluorineFX. This object will be used later in this article with the following code block:
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;
}
}
}
Next you need to provide a FLUORINEFX remote service (that is, an object labeled [Remotingservice]) that provides an externally accessible method interface, the following code block:
namespace FxDotNet.Services
{
[RemotingService]
public class DataServices
{
public DataServices()
{
}
/// <summary>
/// 获取服务端的系统时间
/// </summary>
/// <returns></returns>
public string GetServerTime()
{
return DateTime.Now.ToString();
}
public ArrayCollection GetBooks()
{
ArrayCollection array = new ArrayCollection();
array.Add(new Book(1, "三国演义", "罗贯中", 100.00));
array.Add(new Book(2, "西游记", "吴承恩 ", 200.00));
array.Add(new Book(3, "水浒传", "施耐庵", 300.00));
array.Add(new Book(4, "红楼梦", "曹雪芹", 400.00));
return array;
}
}
}