Web应用程序描述语言
Web应用程序描述语言(Web Application Description Language,WADL)是一个可用计算机处理的表达基于HTTP的Web应用(如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.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.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).
- ^ Richardson, Leonard; Sam Ruby. RESTful Web Services. 徐涵、李红军、胡伟译. 电子工业. 2008年5月: 290 [2008]. ISBN 978-7-121-06227-8 (中文). 引文使用过时参数
coauthors
(帮助) - ^ Lawrence Mandel. Describe REST Web services with WSDL 2.0: A how-to guide. IBM. 29 May 2008 [12 August 2012]. (原始内容存档于2021-01-09).