顯示具有 RESTful 標籤的文章。 顯示所有文章
顯示具有 RESTful 標籤的文章。 顯示所有文章

2013年5月4日 星期六

Webservice Design Style : REST vs SOAP vs XML-RPC

REST(REpresentational State Transfer)

REST是並不是一種標準,只是一種Web Service的設計風格。RESTful則是另一個用來定義Web Service的名詞。

Representational State Transfer or REST basically means that each unique URL is a representation of some object. You can get the contents of that object using an HTTP GET, to delete it, you then might use a POST, PUT, or DELETE to modify the object (in practice most of the services use a POST for this).
It is not necessary to use XML as a data interchange format in REST. The format of information(representation) returned can be in XML, JSON, plain text or even in HTML format.
REST architecture is basically focused on two things : Resources and Interface.


嚴格來說REST符合以下幾個條件:

  • 應用程式的狀態功能拆成 resources
  • 每個 resource 使用獨一無二用來當作超連結的通用定位語法(在WWW中即URI)
  • 所有 resources 共用一致的介面在 client 跟 resource 之間轉換狀態,包括:

    • 一組有限的良好定義操作 well-defined operations (在HTTP中即 GET/POST/PUT/DELETE)
    • 一組有限的內容格式 content types,也許包括 可執行的程式碼 code-on-demand (在WWW中即Javascript)

    SOAP(Simple Object Access Protocol)

    SOAP message are transferred forming the SOAP-Envelope. SOAP is widely criticized for it’s design complexity.


    RPC(Remote Procedure Call)

    在XML的世界裏頭,有兩種方式來實作RPC(Remote Procedure Call): 
    1. XML-based RPC 
    2. SOAP

    RPC 應用程式曝露一或多個網路物件,每個有特定的 functions 可以呼叫。在 client 與物件溝通之前,它必須知道這個物件的知識來操作。

    REST vs SOAP

    The main advantages of REST web services are:
    • Lightweight – not a lot of extra xml markup
    • Human Readable Results
    • Easy to build – no toolkits required
    SOAP also has some advantages:
    • Easy to consume – sometimes
    • Rigid – type checking, adheres to a contract
    • Development tools



    Reference

    2013年4月22日 星期一

    RESTful: REpresentational State Transfer


    什麼是REST?
    REST 是一種分散式超媒體系統(如WWW)的軟體架構風格,可以想像它是Web應用程式的優良設計規則:
    把一組Web Page想像成為具有狀態機(state machine),當client點選hyperlink時則會進行"狀態改變"成為下一個狀態。 
    REST 有什麼優點?
    • 支援快取 caching 將改善反應時間跟server的負載能力。
    • 因為不必維持連結狀態,大大改善 server 的 scalability 能力。這表示不同server可以處理同一串 requests。
    • 一個瀏覽器就可以存取任一應用程式跟資源,client 端不需使用別的軟體。
    • 在HTTP之上不依存其他機制跟軟體。
    • 跟其他連結方式相比(如RPC),可以提供相等的功能。
    • 不需要其他的 discovery 機制,因為使用超連結了。
    • 提供比RPC更好的長期相容性,因為 :
    • 如同HTML這種文件具有後前及向後的相容能力
    • 支援新的內容格式不需要丟掉舊的


    REST  vs RESTful









    Reference