no

How to generate wadl via maven plugin

So you've written your web service and would now want to create the wadl for it.  Assuming you have your web project in eclipse with m...

So you've written your web service and would now want to create the wadl for it.

 Assuming you have your web project in eclipse with maven integrated this is what you have to do: 1.) Add the lines below to your pom, you may want to create it's own profile. For example api.
<plugin>
 <groupId>com.sun.jersey.contribs</groupId>
 <artifactId>maven-wadl-plugin</artifactId>
 <version>1.18.3</version>
 <executions>
  <execution>
   <id>generate</id>
   <goals>
    <goal>generate</goal>
   </goals>
   <phase>compile</phase>
  </execution>
 </executions>
 <configuration>
  <wadlFile>${project.build.directory}/docs/application.wadl</wadlFile>
  <formatWadlFile>true</formatWadlFile>
  <baseUri>http://czetsuya-tech.blogspot.com/api/rest</baseUri>
  <packagesResourceConfig>
   <param>com.broodcamp.api.rest</param>
  </packagesResourceConfig>
  <wadlGenerators>
   <wadlGeneratorDescription>
    <className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc
    </className>
    <properties>
     <property>
      <name>applicationDocsFile</name>
      <value>${project.basedir}/src/main/resources/application-wadl-doc.xml</value>
     </property>
    </properties>
   </wadlGeneratorDescription>
   <wadlGeneratorDescription>
    <className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport
    </className>
    <properties>
     <property>
      <name>grammarsFile</name>
      <value>${basedir}/src/main/resources/application-wadl-grammar.xml</value>
     </property>
    </properties>
   </wadlGeneratorDescription>
  </wadlGenerators>
 </configuration>
</plugin>

2.) Looking at the plugin configuration above, we now have 2 define 2 files:
application-wadl-doc.xml
<?xml version="1.0" encoding="UTF-8"?>
<applicationDocs targetNamespace="http://wadl.dev.java.net/2009/02">
 <doc xml:lang="en" title="czetsuya-tech api">czetsuya-tech api</doc>
</applicationDocs>

application-wadl-grammar.xml
<?xml version="1.0" encoding="UTF-8" ?>
<grammars xmlns="http://wadl.dev.java.net/2009/02" />

3.) Now all you need to do is run the command below in command prompt:
>mvn -Papi clean compile com.sun.jersey.contribs:maven-wadl-plugin:generate
// note that we use api profile as defined above.

Related

source-code-management 4130146659813767627

Post a Comment Default Comments

1 comment

Anonymous said...

can you please provide an example code as a reference as it is not clear from this.

Outsourcing

Are you looking for freelancers in the Philippines? Get in touch.

Donations

If you like what I do, you can support this channel by buying me a coffee. I would be grateful for your contribution! Your donations will help me create more FREE online courses and learning materials for programmers and remote workers.

item