axis2 maven example
Asked Answered
N

4

20

I try to use axis2 (1.5.1) version to generate java codes from wsdl files, but I can't figure out what is the correct pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.5.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                        <wsdlFile>src/main/resources/wsdl/stockquote.wsdl</wsdlFile>
                        <databindingName>xmlbeans</databindingName>
                        <packageName>a.bc</packageName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.5.1</version>
    </dependency>
</dependencies>

when I type mvn compile, it complains the

Retrieving document at 'src/main/resources/wsdl/stockquote.wsdl'.
java.lang.ClassNotFoundException: org.apache.xml.serializer.TreeWalker

And if i try to find the TreeWalker, it is a mess to find a suitable jar files.

can u someone give me a hints ? or give me correct pom.xml

[update] the xalan-2.7.0.jar needs be depedent as well, and the jar file is broken ( due to nexus problem), thx pascal

Northeast answered 22/5, 2010 at 14:22 Comment(1)
I followed the steps described in the accepter answer, but it did not work; Maven still complains about the missing class. Can you post a complete answer with a working POM ?Nowak
H
28

It's maybe not optimal but the following pom.xml seems to allow the generated code to be compiled:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.stackoverflow</groupId>
  <artifactId>Q2888422</artifactId>
  <version>1.0-SNAPSHOT</version>
  ...
  <dependencies>
    <dependency>
      <groupId>org.apache.axis2</groupId>
      <artifactId>axis2</artifactId>
      <version>1.5.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-api</artifactId>
      <version>1.2.6</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-impl</artifactId>
      <version>1.2.6</version>
    </dependency>
    <dependency>
      <groupId>axis</groupId>
      <artifactId>axis-wsdl4j</artifactId>
      <version>1.5.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.xmlbeans</groupId>
      <artifactId>xmlbeans</artifactId>
      <version>2.3.0</version>
    </dependency>
    ...
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
        <version>1.5.1</version>
        <executions>
          <execution>
            <goals>
              <goal>wsdl2code</goal>
            </goals>
            <configuration>
              <wsdlFile>src/main/resources/wsdl/stockquote.wsdl</wsdlFile>
              <databindingName>xmlbeans</databindingName>
              <packageName>a.bc</packageName>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

This pom.xml is the result or try and error plus some googling, I couldn't find a single official or unofficial resource with a working setup. Seriously, why the hell is it so hard to setup an Axis2 project? One more reason I don't like Axis.

Hexachord answered 22/5, 2010 at 19:31 Comment(5)
thank for the comments, and I use the new dep. The error still exists, because the dependance xercesImpl-2.6.2 doesn't have TreeWalker class, only the later version includes this. And I list all the maven dependencies version below (from my eclipse) axis2-1.5.1.jar axiom-api-1.2.6.jar geronimo-activation_1.1_spec-1.0.jar geronimo-javamail_1.4_spec-1.2.jar commons-logging-1.1.1.jar jaxen-1.1.1.jar xml-apis-1.3.04.jar xercesImpl-2.6.2.jar geronimo-stax-api_1.0_spec-1.0.1.jar axiom-impl-1.2.6.jar wstx-asl-3.2.4.jar axis-wsdl4j-1.5.1.jar xmlbeans-2.3.0.jar stax-api-1.0.1.jarNortheast
Ok, it needs depend on xalan and my xalan-2.7.0 is broken again. now the problem is solved, thx.Northeast
This got me on the right path but I had to update the axiom versions to 1.2.8 and also add a dependency on axiom-dom to get it compiling. Thanks for ending a morning of frustration!Residual
With axis2 1.6.1, also neethi is needed: <dependency> <groupId>org.apache.neethi</groupId> <artifactId>neethi</artifactId> <version>3.0.1</version> <packaging>bundle</packaging> </dependency>Heckelphone
It is generating the code inside the target folder. However, when I try to generate all the sources inside src/main/java.. it changes the package configuration and make it src.a.bc. Is there any way to resolve this issue?Enrichetta
P
4

take care that the config must be pushed up (the example is wrong)

    <plugins>
    <plugin>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
        <version>1.5.1</version>
                <configuration>
                    <wsdlFile>src/main/resources/wsdl/stockquote.wsdl</wsdlFile>
                    <databindingName>xmlbeans</databindingName>
                    <packageName>a.bc</packageName>
                </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>wsdl2code</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>
Pet answered 11/4, 2011 at 7:39 Comment(1)
Watch out! I had a similar issue: invoking maven as per the docs: mvn -e axis2-wsdl2code:wsdl2code didn't pick the config. But the config is read properly if you invoke the maven phase instead of the goal: mvn -e generate-sources. It is important to be able to configure every execution independently if you need to generate sources for more than one wsdl.Glabrous
S
3

Thanks to Pascal's pom, I was able to get it working by doing this with the latest versions. In addition:

  • I had to add the build-helper-maven-plugin plugin so that my client classes could access the proxy stubs.
  • I removed the package config option
  • I changed my outputDirectory

Here's my pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourcompany</groupId>
<artifactId>axis2-server-proxy</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<dependencies>
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.6.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ws.commons.axiom</groupId>
        <artifactId>axiom-api</artifactId>
        <version>1.2.15</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ws.commons.axiom</groupId>
        <artifactId>axiom-impl</artifactId>
        <version>1.2.15</version>
    </dependency>
    <dependency>
        <groupId>axis</groupId>
        <artifactId>axis-wsdl4j</artifactId>
        <version>1.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>2.6.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.6.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/</outputDirectory>
                        <wsdlFile>src/main/wsdl/services_visa_com_realtime_realtimeservice_v6_PublicV2.wsdl</wsdlFile>
                        <databindingName>xmlbeans</databindingName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${project.build.directory}/generated-sources/</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Standford answered 30/7, 2015 at 2:23 Comment(0)
A
1

This is an updated version of the pom provided by Pascal Thivent.

The main modifications are that version names are different and neethi is needed.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>my-wsdl2code-example</artifactId>
    <version>1.0</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                <version>1.6.1</version>
                <executions>
                    <execution>
                        <id>execution_id</id>
                        <goals>
                            <goal>wsdl2code</goal>
                        </goals>
                        <configuration>
                            <packageName>com.example.wsdl</packageName>
                            <wsdlFile>src/main/wsdl/web-service.wsdl</wsdlFile>
                            <databindingName>xmlbeans</databindingName>
                        </configuration>
                    </execution>
                </executions>

                <dependencies>

                    <dependency>
                        <groupId>org.apache.xmlbeans</groupId>
                        <artifactId>xmlbeans</artifactId>
                        <version>2.6.0</version>
                    </dependency>

                </dependencies>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.6.1</version>
        </dependency>

        <dependency>
            <groupId>axis</groupId>
            <artifactId>axis-wsdl4j</artifactId>
            <version>1.5.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.neethi</groupId>
            <artifactId>neethi</artifactId>
            <version>3.0.2</version>
        </dependency>


        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-impl</artifactId>
            <version>1.2.14</version>
        </dependency>

        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.6.0</version>
        </dependency>

    </dependencies>

</project>
Acidulate answered 26/3, 2014 at 12:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.