I have working JAX-RS service implemented with CXF. How can I generate wadl? Or is there something like with jersey http://path.to.your/restapp/application.wadl out there already? is there a maven plugin just like for wsdl, java to wsdl? I've searched for answers couldn't find.
2 Answers
If you are using a recent version of CXF, just hit the service with a ?_wadl parameter.

- 14,447
- 4
- 45
- 37
There are a lot of possible ways to generate WADL using CXF:
- You can sent REST call (using Postman, for example) to the base
REST URL and it will automatically create WADL for all services
available from there. It can help to structure REST API. For
example:
- http://app.com/purchase/?_wadl - create WADL for purchase API
- http://app.com/profile/?_wadl - create WADL for user profile API
- CXF 3.0.0 and 2.7.11 introduce java2wadl plugin for generating WADL at the build time. Details clould be found here.
- All available feature of CXF regarding WADL are located in CXF docs.
After WADL has been generated it would be nice to transform XML to more readable form. One of the solutions that I found was XSL usage to generate HTML. I have used XSL from github project. Steps to link XSL to XML and generate pretty HTML report:
- Download wadl.xsl;
- Copy wadl.xsl to the folder that contains wadl.xml file that was generated by CXF;
Add required header to wadl.xml to the very beginning of the file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="wadl.xsl"?>
Replace in wadl.xml generated
<application ...>
header using<wadl:application xmlns:wadl="http://wadl.dev.java.net/2009/02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://wadl.dev.java.net/2009/02 wadl.xsd ">
Add to every tag 'wadl' namespace. For example:
<resource>
-><wadl:resource>
</resource>
-></wadl:resource>
Open wadl.xml using IE
You will get something like this (example_wadl.xml from github project):

- 1,117
- 11
- 10