6

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.

eisbaer
  • 328
  • 1
  • 3
  • 10
  • I am also very close to just using maven-antrun-plugin, which is what my project team has been trying to avoid. – eisbaer Aug 12 '15 at 15:47
  • i updated with that version, which i had tried as well, but wasn't getting anywhere. – eisbaer Aug 12 '15 at 17:26

2 Answers2

4

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.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • thanks, this was helpful. i can't believe how many plugins there are for doing this. – eisbaer Aug 12 '15 at 17:35
  • 1
    I know, right? You should really move avay from Axis and use CXF, unless you need to support (old) RPC encoded WSDL. See [this question](http://stackoverflow.com/questions/1243247/difference-between-apache-cxf-and-axis) for a comparaison of the two. – Tunaki Aug 12 '15 at 17:36
  • i'm afraid i might've answered too soon. looks like this is doing the same thing as the second one i posted above and generating more than what i need. I even tried with the tag:org.apache.axis.wsdl.WSDL2Java – eisbaer Aug 12 '15 at 18:36
0

I gave in and ended up using the antrun plugin for maven:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <phase>process-classes</phase>
            <configuration>
                <tasks>
                    <java classname="org.apache.axis.wsdl.WSDL2Java" fork="true">
                        <arg value="-client"/>
                        <arg value="-o"/>
                        <arg value="gensrc"/>
                        <arg value="wsdl/JobAPIWebWrapped.wsdl"/>
                        <classpath refid="maven.compile.classpath"/>
                    </java>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
eisbaer
  • 328
  • 1
  • 3
  • 10