|
|
||
Marc Hadley's BlogJune 2006 ArchivesWADL EnhancementsPosted by mhadley on June 30, 2006 at 01:07 PM | Permalink | Comments (5)In this entry I describe some of the language enhancements that will be in the next version of the WADL specification. These enhancements are the result of feedback I've received from other folks using the language and experience gained implementing a Java processor for WADL.
Resource ReferencesCurrently you can define a method or representation in one place and then include that definition by reference elsewhere. This is useful if the same representation is used in multiple method definitions or if the same method applies to more than one resource. Extending this capability to the <application>
<resources base="http://example.com/">
<resource href="stock">
<resource href="#widgets"/>
</resource>
<resource href="order">
<resource href="#widgets"/>
</resource>
</resources>
<resource id="widgets" path="widgets">
...
</resource>
</application>
Identification of LinksWhilst it would be possible at runtime to compare a URI embedded in a representation with the URIs of all of the resources in a WADL description to identify which resource it identifies, it would be preferable to be able to specify the resource targeted by a link up front where that information is known.
This is achieved in WADL by adding a new element to the language: E.g., if an application consists of the resources:
and a GET on the first resource gets me a <eg:WidgetList xmlns:eg="..."> <eg:Widget uri="http://example.com/widgets/xyzzy1"/> <eg:Widget uri="http://example.com/widgets/abccb1"/> ... </eg:WidgetList> such that <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 DocumentationThe content model of WADL-defined elements is open for extension and I originally thought that documentation could be added by including html or xhtml elements within a WADL description. Thinking on this some more I've come to the conclusion that it would be better to define a standard <application>
<documentation><p>An online widget catalogue.</p></documentation>
<resources base="http://example.com/">
<documentation><p>Commercial widgets.</p></documentation>
...
</resources>
</application>
Multi-segment Resource PathsIts a pain to require multiple nested <resources base="http://example.com/">
<resource uri="applications/catalogues/widgets">
...
</resource>
</resources>
instead of <resources base="http://example.com/">
<resource uri="applications">
<resource uri="catalogues">
<resource uri="widgets">
...
</resource>
</resource>
</resource>
</resources>
Much more compact and readable ! Matrix URI SupportThe <resource uri="widgets"> <path_variable name="maxPrice" type="xsd:decimal" matrix="true"/> <path_variable name="minPrice" type="xsd:decimal" matrix="true"/> ... </resource> If the value of widgets;maxPrice=10.00;minPrice=5.00 A null value for a matrix path variable results in it being omitted from the uri. Still on the Drawing BoardOther enhancements still on the drawing board include:
| ||
|
|