Web應用程式描述語言

本頁使用了標題或全文手工轉換
維基百科,自由的百科全書

Web應用程式描述語言Web Application Description Language,WADL)是一個可用電腦處理的表達基於HTTPWeb應用(如RESTWeb服務)的XML詞彙。[1] WADL描述了Web服務提供的資源及他們的聯絡。[1] WADL試圖簡化重用基於HTTP架構的Web服務。[1][2]它是一個平台,且與語言無關,並試圖推動除Web瀏覽器的基本使用外的應用重用。[1]

WADL於2009年8月31日由昇陽電腦提交至全球資訊網協會[1],但聯盟目前沒有標準化它的計劃[2]並且它並沒有被廣泛地支援。WADL依照描述基於SOAP的RPC式服務的XML詞彙WSDL定義,用於描述REST服務[3],而WSDL也可用於描述RESTWeb服務。[4]

格式[編輯]

服務用一系列的資源(resource)標籤描述。每一個resource包含參數(param)元素描述輸入,而方法(method)元素描述對一個resource的請求(request)和回應(response)。request標籤定義了如何表達輸入,它要求定義對應的類型和特定的HTTP頭。response標籤定義了服務的回應及所有錯誤資訊,用於處理錯誤。

例子[編輯]

下列是一個以WADL描述的雅虎新聞搜尋程式。

 <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://wadl.dev.java.net/2009/02 wadl.xsd" 
  xmlns:tns="urn:yahoo:yn" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:yn="urn:yahoo:yn" 
  xmlns:ya="urn:yahoo:api" 
  xmlns="http://wadl.dev.java.net/2009/02"> 
   <grammars> 
     <include 
       href="NewsSearchResponse.xsd"/> 
     <include 
       href="Error.xsd"/> 
   </grammars> 
 
   <resources base="http://api.search.yahoo.com/NewsSearchService/V1/"> 
     <resource path="newsSearch"> 
       <method name="GET" id="search"> 
         <request> 
           <param name="appid" type="xsd:string" 
             style="query" required="true"/> 
           <param name="query" type="xsd:string" 
             style="query" required="true"/> 
           <param name="type" style="query" default="all"> 
             <option value="all"/> 
             <option value="any"/> 
             <option value="phrase"/> 
           </param> 
           <param name="results" style="query" type="xsd:int" default="10"/> 
           <param name="start" style="query" type="xsd:int" default="1"/> 
           <param name="sort" style="query" default="rank"> 
             <option value="rank"/> 
             <option value="date"/> 
           </param> 
           <param name="language" style="query" type="xsd:string"/> 
         </request> 
         <response status="200"> 
           <representation mediaType="application/xml" 
             element="yn:ResultSet"/> 
         </response> 
         <response status="400"> 
           <representation mediaType="application/xml" 
             element="ya:Error"/> 
         </response> 
       </method> 
     </resource> 
   </resources>

參考來源[編輯]

  1. ^ 1.0 1.1 1.2 1.3 1.4 Sun Microsystems. Web Application Description Language: W3C Member Submission 31 August 2009. World Wide Web Consortium. 31 August 2009 [12 August 2012]. (原始內容存檔於2022-11-29). 
  2. ^ 2.0 2.1 World Wide Web Consortium. Team Comment on the "Web Application Description Language" Submission. World Wide Web Consortium. 14 October 2009 [12 August 2012]. (原始內容存檔於2022-11-27). 
  3. ^ Richardson, Leonard; Sam Ruby. RESTful Web Services. 徐涵、李紅軍、胡偉譯. 電子工業. 2008年5月: 290 [2008]. ISBN 978-7-121-06227-8 (中文). 
  4. ^ Lawrence Mandel. Describe REST Web services with WSDL 2.0: A how-to guide. IBM. 29 May 2008 [12 August 2012]. (原始內容存檔於2021-01-09). 

外部連結[編輯]