Search code examples
javasoapwsdlwsdl2java

How to generate SOAP stubs in Java?


It's the first I am working with SOAP interface.

I have WSDL that I suppose to generate stub classes from.

I use axistools-maven-plugin but not all classes were generated. For instance, ConnectWithToken wasn't present into generated stubs.

My pom.xml plugins section:

<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>axistools-maven-plugin</artifactId>
    <version>${axis.version}</version>
    <configuration>
      <urls>
        <url>https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?WSDL</url>
      </urls>
      <outputDirectory>${basedir}/src/main/java</outputDirectory>
      <subPackageByFileName>true</subPackageByFileName>
      <verbose>true</verbose>
      <allElements>true</allElements>
      <indentSize>4</indentSize>
    </configuration>
  </plugin>
</plugins>

Is it the way for me to generate all classes specified into wsdl using above plugin?


Solution

  • My solution was to change SOAP class generator provider. QA helped a lot but I had to adopt solution based on the jaxws-maven-plugin plugin documentation and project.

    pom.xml dependencies section:

    <dependency>
          <groupId>com.sun.xml.ws</groupId>
          <artifactId>jaxws-rt</artifactId>
          <version>2.2.10</version>
    </dependency>
    

    pom.xml build section:

    <build>
        <plugins>
    
            <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jaxws-maven-plugin</artifactId>
                    <version>2.5</version>
                    <executions>
                        <execution>
                            <id>generate-source-by-wsdl</id>
                            <goals>
                                <goal>wsimport</goal>
                            </goals>
                            <phase>generate-sources</phase>
                            <configuration>
                                <vmArgs>
                                    <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                                </vmArgs>
                                <wsdlUrls>
                                    <wsdlUrl>https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?WSDL</wsdlUrl>
                                </wsdlUrls>
                                <sourceDestDir>src/main/java</sourceDestDir>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    
        </plugins>
    </build>