Nothing Special   »   [go: up one dir, main page]

Jump to content

Web Application Description Language

From Wikipedia, the free encyclopedia

The Web Application Description Language (WADL) is a machine-readable XML description of HTTP-based web services.[1] WADL models the resources provided by a service and the relationships between them.[1] WADL is intended to simplify the reuse of web services that are based on the existing HTTP architecture of the Web.[1][2] It is platform and language independent and aims to promote reuse of applications beyond the basic use in a web browser.[1] WADL was submitted to the World Wide Web Consortium by Sun Microsystems on 31 August 2009[1], but the consortium has no current plans to standardize it[2]. WADL is the REST equivalent of SOAP's Web Services Description Languages (WSDL), which can also be used to describe REST web services.[3]

Format

[edit]

The service is described using a set of resource elements. Each resource contains param elements to describe the inputs, and method elements which describe the request and response of a resource. The request element specifies how to represent the input, what types are required and any specific HTTP headers that are required. The response describes the representation of the service's response, as well as any fault information, to deal with errors.

Example

[edit]

The following listing shows an example of a WADL description for the Yahoo News Search application.

 <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:yn="urn:yahoo:yn" xmlns:ya="urn:yahoo:api"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  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>
 </application>

Generate WADL or generate code from WADL

[edit]

Java

[edit]

There are multiple tools to generate java code from an existing WADL:[4][5]

Example WADL Generated by CXF

[edit]
<app xmlns="http://research.sun.com/wadl/2006/10" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <grammars>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
               elementFormDefault="unqualified">
      <xs:element name="appProfile" type="appProfile"/>
      <xs:element name="customerProfile" type="customerProfile"/>
      <xs:complexType name="customerProfile">
        <xs:sequence>
          <xs:element minOccurs="0" name="accessPaymentServicesEnabled" type="xs:boolean"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="attributes" nillable="true" type="attribute"/>
          <xs:element minOccurs="0" name="billingType" type="xs:string"/>
          <xs:element minOccurs="0" name="defaultCurrency" type="xs:string"/>
          <xs:element minOccurs="0" name="defaultSpendingLimitCurrency" type="xs:string"/>
          <xs:element minOccurs="0" name="maximumSpendingLimit" type="xs:double"/>
          <xs:element minOccurs="0" name="minimumSpendingLimit" type="xs:double"/>
          <xs:element minOccurs="0" name="customerCategory" type="xs:string"/>
          <xs:element minOccurs="0" name="customerEnabled" type="xs:boolean"/>
          <xs:element minOccurs="0" name="customerName" type="xs:string"/>
          <xs:element minOccurs="0" name="paymentNotificationEndpointAddress" type="xs:string"/>
          <xs:element minOccurs="0" name="pseCustomerId" type="xs:string"/>
          <xs:element minOccurs="0" name="resourceURL" type="xs:string"/>
          <xs:element minOccurs="0" name="settlementContractUuid" type="xs:string"/>
          <xs:element minOccurs="0" name="isSpendingLimitEnabled" type="xs:boolean"/>
          <xs:element minOccurs="0" name="abcCustomerId" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="attribute">
        <xs:sequence>
          <xs:element minOccurs="0" name="key" type="xs:string"/>
          <xs:element minOccurs="0" name="value" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="appProfile">
        <xs:sequence>
          <xs:element minOccurs="0" name="appEnabled" type="xs:boolean"/>
          <xs:element minOccurs="0" name="appName" type="xs:string"/>
          <xs:element minOccurs="0" name="appPassword" type="xs:string"/>
          <xs:element minOccurs="0" name="appUserName" type="xs:string"/>
          <xs:element minOccurs="0" name="appUuid" type="xs:string"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="attributes" nillable="true" type="attribute"/>
          <xs:element minOccurs="0" name="description" type="xs:string"/>
          <xs:element minOccurs="0" name="customerName" type="xs:string"/>
          <xs:element minOccurs="0" name="resourceURL" type="xs:string"/>
          <xs:element minOccurs="0" name="serviceContractName" type="xs:string"/>
          <xs:element minOccurs="0" name="abcAppId" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </grammars>
  <resources base="http://mpsamara-mobl-vm1:9078/customermanagement/v1">
    <resource path="/customers">
      <resource path="/">
        <method name="DELETE">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
        <method name="GET">
          <request>
            <param name="page" style="query" type="xs:int"/>
            <param name="partialCustomerName" style="query" type="xs:string"/>
          </request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
        <method name="POST">
          <request>
            <representation mediaType="app/json"/>
          </request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
        <method name="PUT">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}">
        <method name="DELETE">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}">
        <param name="customerUserName" style="template" type="xs:string"/>
        <method name="GET">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
        <method name="POST">
          <request>
            <representation mediaType="app/json"/>
          </request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}">
        <method name="PUT">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}/apps">
        <method name="DELETE">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}/apps">
        <param name="customerUserName" style="template" type="xs:string"/>
        <method name="GET">
          <request>
            <param name="page" style="query" type="xs:int"/>
          </request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
        <method name="POST">
          <request>
            <representation mediaType="app/json"/>
          </request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}/apps">
        <method name="PUT">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}/apps/{appName}">
        <method name="DELETE">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}/apps/{appName}">
        <param name="customerUserName" style="template" type="xs:string"/>
        <param name="appName" style="template" type="xs:string"/>
        <method name="GET">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
        <method name="POST">
          <request>
            <representation mediaType="app/json"/>
          </request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
      <resource path="/{customerUserName}/apps/{appName}">
        <method name="PUT">
          <request></request>
          <response>
            <representation mediaType="app/json"/>
          </response>
        </method>
      </resource>
    </resource>
  </resources>
</app>

See also

[edit]

References

[edit]
  1. ^ a b c d e Sun Microsystems (31 August 2009). "Web Application Description Language: W3C Member Submission 31 August 2009". World Wide Web Consortium. Retrieved 12 August 2012.
  2. ^ a b World Wide Web Consortium (14 October 2009). "Team Comment on the "Web Application Description Language" Submission". World Wide Web Consortium. Retrieved 12 August 2012.
  3. ^ Lawrence Mandel (29 May 2008). "Describe REST Web services with WSDL 2.0: A how-to guide". IBM. Retrieved 12 August 2012.
  4. ^ github WADL project
  5. ^ Apache CXF
[edit]