Maven2 Java2WSDL Plug-in Guide

Introduction

This plugin takes as input a Java class and generates a WSDL, which describes a Web service for invoking the classes methods.

[Download Plugin Tool]

Goals

The Java2WSDL plugin offers a single goal:

  • java2wsdl (default): Reads a java class and generates a WSDL for invoking the classes methods as a Web service.

To run the plugin, add the following section to your POM (Project Object Model):

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-java2wsdl-maven-plugin</artifactId>
        <configuration>
          <className>com.foo.myservice.MyHandler</className>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>java2wsdl</goal>
            </goals>
          </execution>
         </executions>
      </plugin>
    </plugins>
  </build>
  

The plugin will be invoked automatically in the generate-resources phase. You can also invoke it directly from the command line by running the command:

mvn axis2-java2wsdl:java2wsdl

The Java2WSDL Goal

By default, the plugin reads the given Java class and creates a file target/generated-resources/java2wsdl/service.wsdl . The Java class is given by the configuration element className above.

Configuration

The Java2WSDL goal takes the following parameters as input. All parameters can be set from the command line by using properties. For example, the parameter "className" may be set using the property "axis2.java2wsdl.className". If the parameter isn't set via property or in the POM, then a default value applies.

Parameter name Command line property Description Default value
className ${axis2.java2wsdl.className} Fully qualified name of the class, which is being read and transformed into a WSDL
outputFileName ${axis2.java2wsdl.outputFileName} Path of the generated service file.
schemaTargetNamespace ${axis2.java2wsdl.schemaTargetNamespace} Target namespace of the generated schema.
schemaTargetNamespacePrefix ${axis2.java2wsdl.schemaTargetNamespacePrefix} Prefix, which is being associated with the schemas target namespace.
serviceName ${axis2.java2wsdl.serviceName} Name of the generated Web service. Unqualified name of the input class.
targetNamespace ${axis2.java2wsdl.targetNamespace} Target namespace of the generated WSDL Default namespace
targetNamespacePrefix ${axis2.java2wsdl.targetNamespacePrefix} Prefix, which is being associated with the target namespace