WADL (Web Application Description Language) is an XML description of HTTP based web services.
We can assume it as equivalent to WSDL used in SOAP services.
Format of WADL
Resource is defined with its method (with request and response sub element) element.
param elements defines the inputs with name and type.
Example
<application ...>
<resources base="URL">
<resource path="search">
<method name="GET" id="search">
<request>
<param name="id" type="xsd:string"
style="query" required="true"/>
<param name="start" style="query" type="xsd:int" default="1"/>
<param name="sort" style="query" default="name">
<option value="name"/>
<option value="city"/>
</param>
<param name="language" style="query" type="xsd:string" />
</request>
<response status="200">
<representation mediaType="application/xml"
element="shaanns:ResultSet"/>
</response>
<response status="400">
<representation mediaType="application/xml"
element="shaanns:Error"/>
</response>
</method>
</resource>
</resources>
</application>
How to generate WADL or code from WADL ?
In Java, You can use Apache CXF or JAX-RS implementation like, Jersey.
Generate Java code using wadl2java
wadl2java -o outputDir -p package [-a] [-s jaxrs20] [-c customization]* file.wadl
Example
wadl2java -o out -p com.shaan.service myservice.wadl
Generate WADL using Jersey
Generate WADL using Spring REST
No comments:
Post a Comment
Note: only a member of this blog may post a comment.