REST WADL / Extending WadlGenerator in CXF

 REST WADL / Extending WadlGenerator in CXF


A problem in the world of wadl, is that the documentation level on the wadl level is not great.

An example:

<resource path="/agents">

                <method name="GET">


                                                <param name="externalAgentRef" style="query" type="xs:string"/>



                                                <representation mediaType="application/json"/>





In this example you can see that the default WadlGenerator will display all parameters in the input, but the output is defined as application/json. What we want is for the xml to describe the object that is serialized on the output.


To do this we need do define a provider for the jaxrs:


<bean class="...WadlGeneratorEx">

<property name="linkJsonToXmlSchema" value="true" />




CXF does not have a standard interface for the Wadl generator, so you need to extend the current WadlGenerator (

Since the class was not created properly for overriding methods, I copied to whole class to a new class with the inheritance of:

public class WadlGeneratorEx extends WadlGenerator implements RequestHandler

On the method: private void handleRepresentation, I added the following line:

sb.append(" classImpl=\"").append(type.getSimpleName()).append("\"");


The new output looks like:

<representation mediaType="application/json" classImpl="Agent"/>


You can now add any other xml attributes you need for documentation.