maven wsdl2java configuration not working properly

eisbaer picture eisbaer · Aug 12, 2015 · Viewed 9.8k times · Source

I am looking to execute wsdl2java via maven and have tried several different methods with no full success. The first way I was doing it:

<plugin>  
    <groupId>org.codehaus.mojo</groupId>  
    <artifactId>exec-maven-plugin</artifactId>  
    <version>1.1</version>  
    <executions>  
        <execution>  
            <phase>compile</phase>  
            <goals>  
                <goal>java</goal>  
            </goals>  
            <configuration>  
                <mainClass>org.apache.axis.wsdl.WSDL2Java</mainClass>  
                <arguments>  
                    <argument>-client</argument>  
                    <argument>-o</argument>  
                    <argument>gensrc</argument>  
                    <argument>wsdl/JobAPIWebWrapped.wsdl</argument>  
                </arguments>  
            </configuration>  
        </execution>  
    </executions>  
</plugin>

This version will create the exact structure that I am looking for due to the call to org.apache.axis.wsdl.WSDL2Java, but will not continue with any other maven plugins beyond that. It ends the log with executing main or something to that effect.

The other method I have tried:

<plugin>  
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.1.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>gensrc</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>wsdl/JobAPIWebWrapped.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The problem with this execution is that it generates a lot more java files than the previous execution stated higher up. I have checked the compatibility of this larger fileset and found it will work fine, but would like to find a way to force it to execute with the same java class as the first example. This version will, however, complete and allow me to move on to the following plugins called by maven.

Third:

<plugin> 
    <groupId>org.apache.axis</groupId>
    <artifactId>wsdl2java-maven-plugin</artifactId>
    <version>1.4.1-SNAPSHOT</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
        <implementationClassName>org.apache.axis.wsdl.WSDL2Java</implementationClassName>
            </configuration>
        </execution>
    </executions>
</plugin>

This version isn't even being recognized... wondering if I am calling the plugin incorrectly because it isn't even showing up anywhere with verbose logging.

I have been searching quite a bit and have yet to find a successful answer. I am very close to just writing a shell script to run the maven set-up by calling the first example then moving on. Any help is greatly appreciated. Thanks.

Answer

Tunaki picture Tunaki · Aug 12, 2015

Instead of using the exec-maven-plugin invoking WSDL2Java, you should use axistools-maven-plugin. Your pom would look like this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>axistools-maven-plugin</artifactId>
    <version>1.4</version>
    <configuration>
        <wsdlFiles>
            <wsdlFiles>wsdl/JobAPIWebWrapped.wsdl</wsdlFiles>
        </wsdlFiles>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

By the way, Apache Axis is quite old and broken. You should think about moving to Apache CXF which is more recent and more robust.