因為項目需要,在技術選型的時候,需要在Flex 用戶端和 PHP伺服器端選擇一個基礎協議。
目前有集中選擇:
1.AMFPHP(http://www.amfphp.org/)
AMF是Action Message Format協議的簡稱,AMF協議是Adobe公司自己的協議,主要用於資料互動和遠端程序呼叫,在功能上相當於WebService,但是AMF與WebService中的XML不同的是AMF是位元據,而XML是文本資料,AMF的傳輸效率比XML高。AMF使用HTTP方式傳輸,目前主要是用於ActionScript中,即實現Flex和Server之間的通訊。
2.JSON(http://www.json.org/json-zh.html)
JSON(JavaScript Object Notation) 是一種輕量級的資料交換格式。易於人閱讀和編寫。同時也易於機器解析和產生。它基於JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999的一個子集。 JSON採用完全獨立於語言的文字格式設定,但是也使用了類似於C語言家族的習慣(包括C, C++, C#, Java, JavaScript, Perl, Python等)。這些特性使JSON成為理想的資料交換語言。
這是其他人的一個效能評測報告,考慮到AMFPHP是二進位,並且是官方支援的,所以還是選擇AMFPHP好了
In the tests, I use the AMFPHP library, which you'll need for the AMFPHP test. I use the Zend Framework for the JSON library, converting my PHP Array to JSON. JSON is handled in Flex with the use of the JSON library. The XML test is the simplest of all, simply printing out the XML without having to load any other library or files.
Here's the data (times are in ms):
# of data
|
XML |
AMFPHP |
JSON
|
5000 |
1903 |
2033
|
2814 |
10000 |
3625 |
3495
|
4747 |
15000 |
4326 |
4867
|
6830 |
20000 |
5939 |
6550
|
9094 |
25000 |
6570 |
7942
|
11838 |
30000 |
8473 |
10335
|
14512 |
35000 |
9594 |
12389
|
17716 |
40000 |
10885 |
14651
|
20480 |