Fork me on GitHub

Using Web Services Tools from JDK

Using JDK Maven Toolchain

Starting with version 2.4, jaxws-maven-plugin supports Maven toolchains: if a JDK Toolchain is defined, wsgen and wsimport tools can be used from this toolchain by setting useJdkToolchainExecutable parameter to true.

<project>
  ...
  <build>
    ...
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <useJdkToolchainExecutable>true</useJdkToolchainExecutable>
          ...
        </configuration>
      </plugin>
      ...
    </plugins>
    ...
  <build>
  ...
<project>

For details on using toolchains, see Maven guide to using toolchains.

Without Toolchains

<project>
  ...
  <build>
    ...
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>wsgen-from-jdk</id>
            <goals>
              <goal>wsgen</goal>
            </goals>
            <configuration>
              <executable>${tool.wsgen}</executable>
              <sei>com.mycompany.MyService</sei>
              ...
            </configuration>
          </execution>
          <execution>
            <id>wsimport-from-jdk</id>
            <goals>
              <goal>wsimport</goal>
            </goals>
            <configuration>
              <executable>${tool.wsimport}</executable>
              <wsdlUrls>
                <wsdlUrl>http://example.org/sample.wsdl</wsdlUrl>
              </wsdlUrls>
              ...
            </configuration>
          </execution>
          ...
        </executions>
      </plugin>
      ...
    </plugins>
    ...
  <build>
  ...

  <!-- setup corresponding executables on win/*nix -->
  <profiles>
    <profile>
      <id>win</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <tool.wsgen>${java.home}/../bin/wsgen.exe</tool.wsgen>
        <tool.wsimport>${java.home}/../bin/wsimport.exe</tool.wsimport>
      </properties>
    </profile>
    <profile>
      <id>nix</id>
      <activation>
        <os>
          <family>!windows</family>
        </os>
      </activation>
      <properties>
        <tool.wsgen>${java.home}/../bin/wsgen</tool.wsgen>
        <tool.wsimport>${java.home}/../bin/wsimport</tool.wsimport>
      </properties>
    </profile>
    ...
  </profiles>
</project>