Describing links in WADL

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Describing links in WADL

Marc Hadley

A number of folks have pointed out that it would be useful to be able  
to describe the linkages between described resources in addition to  
the HTTP methods that can be applied to those resources and the  
representation formats supported. Whilst it would be possible at  
runtime to compare a URI with the URIs of all of the resources in a  
description to identify a match, I think it would be preferable to be  
able to specify the resource targeted by a link up front where that  
information is known.

This can be achieved in WADL by adding a new element to the language:  
<link>. The <link> element can be used as a child of the existing  
<representation_variable> element and is used to indicate that the  
value of a representation component is a link to a described  
resource. The <link> element is syntactically similar to the HTML  
<link> element but differs semantically in that its href attribute  
identifies a <resource> element rather than a linked document. The  
parent <representation_variable> element identifies that part of the  
representation that contains the link. E.g.

If an application consists of the resources:

http://example.com/widgets
http://example.com/widgets/{widgetid} (where {widgetid} is a variable  
component to the URI)

and a GET on the first resource gets me a WidgetList:

<eg:WidgetList xmlns:eg="...">
   <eg:Widget uri="http://example.com/widgets/xyzzy1"/>
   <eg:Widget uri="http://example.com/widgets/abccb1"/>
   ...
</eg:WidgetList>

such that eg:Widget/@uri links to one of the "http://example.com/ 
widgets/{widgetid}" resources, then this can be described as follows:

<application xmlns:...>

   <resources base="http://example.com/">
     <resource uri="widgets">
       <method href="#widgetList"/>
       <resource id="widgetResource" uri="{widgetid}">
         ...
       </resource>
     </resource>
   </resources>

   <method name="GET" id="widgetList">
     <response>
       <representation mediaType="application/xml"  
element="eg:WidgetList">
         <representation_variable path="/Widgets/Widget/@uri"  
repeating="true">
           <link href="#widgetResource" rel="child" rev="index"/>
         </representation_variable>
       </representation>
     </response>
   </method>

</application>

The values of the rel and rev attributes are an open set including  
those used by convention in HTML. Similar to HTML, a profile  
attribute may be added to the application element to define a  
namespace for additional link types.

Thoughts, comments ?
Marc.

---
Marc Hadley <marc.hadley at sun.com>
Business Alliances, CTO Office, Sun Microsystems.