Create wadl from existing CXF service

I have a JAX-RS service implemented with CXF. How can i generate wadl? Or is there something like with a shirt http: //path.to.your/restapp/application.wadl there already? is there a maven plugin like wsdl, java for wsdl? I was looking for answers that could not be found.

+3
source share
2 answers

If you are using the latest version of CXF, just click the service with the _wadl parameter.

+17
source

There are many possible ways to generate WADL using CXF:

  • You can send a REST call (e.g. Postman ) to the REST URL base, and it will automatically create a WADL for all services available from there. This can help structure the REST API. For example:
  • CXF 3.0.0 and 2.7.11 are a java2wadl plugin for generating WADL during build. Details can be found here .
  • All of the available CXF functionality regarding WADL is in the CXF docs .

After creating WADL, it would be convenient to convert XML to a more readable form. One solution I found was to use XSL to generate HTML. I used XSL from the github project . The steps for linking XSL to XML and generating a pretty HTML report:

  • Download wadl.xsl;
  • Copy the wadl.xsl file to the folder containing the wadl.xml file that CXF generated;
  • Add the required header in wadl.xml to the top of the file:

    <?xml version="1.0" encoding="UTF-8"?>

    <?xml-stylesheet type="text/xsl" href="wadl.xsl"?>

  • Replace the <application ...> header in the created wadl.xml 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 each wadl tag namespace. For instance:

    <resource> β†’ <wadl:resource>

    </resource> β†’ </wadl:resource>

  • Open wadl.xml with IE

  • You will get something like this (example_wadl.xml from the github project ): HTML page generated from WADL file

+4
source

Source: https://habr.com/ru/post/1212664/


All Articles