Using multiple WSDLs with Axis2 wsdl2code Maven plugin

15,628

You can try with this, i could not test it right now but i think should work

   <plugin>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
            <execution>
                <id>ws1</id>
                <goals>
                    <goal>wsdl2code</goal>
                </goals>
                <configuration>
                   <unpackClasses>true</unpackClasses>
                   <databindingName>adb</databindingName>
                   <packageName>org.example.stackoverflow.axis2-maven</packageName>
                   <wsdlFile>src/main/resources/service1.wsdl</wsdlFile>
                   <outputDirectory>target/generated-sources</outputDirectory>
                   <syncMode>sync</syncMode>
                </configuration>
            </execution>
            <execution>
                <id>ws2</id>
                <goals>
                    <goal>wsdl2code</goal>
                </goals>
                <configuration>
                   <unpackClasses>true</unpackClasses>
                   <databindingName>adb</databindingName>
                   <packageName>org.example.stackoverflow.axis2-maven</packageName>
                   <wsdlFile>src/main/resources/service2.wsdl</wsdlFile>
                   <outputDirectory>target/generated-sources</outputDirectory>
                   <syncMode>sync</syncMode>
                </configuration>
            </execution>
        </executions>
    </plugin>
Share:
15,628
David J. Liszewski
Author by

David J. Liszewski

Updated on June 18, 2022

Comments

  • David J. Liszewski
    David J. Liszewski almost 2 years

    I'm creating a client with Maven2 that uses several web services. I'm restricted to using Axis2 or other framework supporting Apache HttpClient as an HTTP conduit because these services require integration with a managed certificate solution based on HttpClient.

    I'm familiar with CXF's code-gen Maven plugin which allows multiple WSDLs to be input during code generation. However, the Axis2 code-gen plugin can process only one WSDL at a time.

    How can I make Maven run wsdl2code for each WSDL during code-gen phase? Do I need multiple profiles for this?

    The build section of POM looks like this:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsdl2code</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <unpackClasses>true</unpackClasses>
                    <databindingName>adb</databindingName>
                    <packageName>org.example.stackoverflow.axis2-maven</packageName>
                    <!-- only one of these actually gets used by code generator -->
                    <wsdlFile>src/main/resources/service1.wsdl</wsdlFile>
                    <wsdlFile>src/main/resources/service2.wsdl</wsdlFile>
                    <outputDirectory>target/generated-sources</outputDirectory>
                    <syncMode>sync</syncMode>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    References

  • David J. Liszewski
    David J. Liszewski almost 13 years
    Yea, that did it, thanks. Note that POM didn't validate as is. I got: You cannot have two plugin executions with the same (or missing) <id/> elements. message. After adding a unique <id> to each execution, it was all good.
  • ArunM
    ArunM almost 11 years
    What if I have 50 WSDL's that needs to be generated. Is this possible using the maven plugin ?
  • AppleBud
    AppleBud over 10 years
    how can I change the output directory location to src/main/java/.. When I am doing it, it is changing the packageName and makes it src.org.example............ How can I resolve this?
  • guido
    guido over 10 years
    @AppleBud For the sources directory use the ${project.build.sourceDirectory} property; however, it is not an healthy practice to generate stuff in the sources directory during the build process. So you better turn off the automatic generation in the generate-sources phase, by using ` <phase>never</phase>` in the execution configuration, and then invoke the goal directly when needed.
  • AppleBud
    AppleBud over 10 years
    okie, thanks. Is there any way I can make my pom.xml to skip a particular goal?
  • guido
    guido over 10 years
    @AppleBud goals are only executed when they are bound to phases defined in the maven build life-cycle. By default, axis2-maven plugin binds to the generate-sources phase, so it get executed. To unbind it, as i said, and assuming you are using maven 3, just use <phase/> or <phase>never</phase> (never is a non-existing phase) like described here: stackoverflow.com/questions/7800647/…