Flex vs. NET Interop (14): FluorineFX's AMF (Action message Format) protocol communication

Source: Internet
Author: User

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;
        }
    }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.