Multiple WSDL configurations with Maven JAXWS

I need to include more than one WSDL in my Maven JAXWS configuration, and I need to specify different output directories for them, as some method names in wsdlA conflict with method names in wsdlB. I am using org.jvnet.jax-ws-commons and I need bindings to apply only to wsdlA, not wsdlB.

This is what I have at the moment:

<build> <pluginManagement> <plugins> <plugin> <groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.1</version> <executions> <execution> <goals> <goal>wsimport</goal> </goals> </execution> </executions> <configuration> <!-- Configure Output --> <packageName>com.mycee.project.model</packageName> <sourceDestDir>src/main/java</sourceDestDir> <!-- Configure WSDL Location --> <wsdlFiles> <wsdlFile> ${basedir}/src/jaxws/wsdl/wsdla.wsdl </wsdlFile> <!-- <wsdlFile> ${basedir}/src/jaxws/wsdl/wsdlb.wsdl </wsdlFile> --> </wsdlFiles> <!-- Configure Binding Location --> <bindingDirectory> ${basedir}/src/jaxws/binding </bindingDirectory> <!-- Make Output Verbose --> <verbose>true</verbose> </configuration> </plugin> </plugins> </pluginManagement> </build> 

UPDATED:

 <build> <pluginManagement> <plugins> <!-- WSDL GENERATOR PLUGIN --> <!-- mvn jaxws:wsimport --> <plugin> <groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.3</version> <executions> <!-- WSDL A --> <execution> <id>WSDLA</id> <phase>generate-sources</phase> <goals> <goal>wsimport</goal> </goals> <configuration> <packageName>com.mycee.project.model.wsdla</packageName> <staleFile>${project.build.directory}/jaxws/stale/wsdl.a.done</staleFile> <wsdlFiles> <wsdlFile>${basedir}/src/jaxws/wsdl/wsdla.wsdl</wsdlFile> </wsdlFiles> <bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory> </configuration> </execution> <!-- WSDL B --> <execution> <id>WSDLB</id> <phase>generate-sources</phase> <goals> <goal>wsimport</goal> </goals> <configuration> <packageName>com.mycee.project.model.wsdlb</packageName> <staleFile>${project.build.directory}/jaxws/stale/wsdl.b.done</staleFile> <wsdlFiles> <wsdlFile>${basedir}/src/jaxws/wsdl/wsdlb.wsdl</wsdlFile> </wsdlFiles> </configuration> </execution> </executions> <!-- Common Config --> <configuration> <verbose>true</verbose> <wsdlDirectory> ${basedir}/src/jaxws/wsdl </wsdlDirectory> </configuration> </plugin> </plugins> </pluginManagement> </build> 

When I run mvn clean jaxws: wsimport, I get the following notification without creating Java code:

[INFO] --- jaxws-maven-plugin: 2.2: wsimport (default-cli) @ [INFO] No WSDLs were found, specify at least one of the following parameters: wsdlFiles, wsdlDirectory or wsdlUrls.

+7
maven jax-ws
source share
2 answers

First of all, you do not need to configure the pluginManagement block. In this case, it is better to determine the version of the plugin only in the pluginManagement block. In addition, to fulfill your requirement you need to perform two executions:

  <plugin> <groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> <executions> <execution> <id>wsdla-exec</id> <goals> <goal>wsimport</goal> </goals> <configuration> <packageName>com.mycee.project.model</packageName> <wsdlFiles> <wsdlFile>${basedir}/src/jaxws/wsdl/wsdla.wsdl</wsdlFile> </wsdlFiles> <bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory> <verbose>true</verbose> </configuration> </execution> <execution> <id>wsdlb-exec</id> <goals> <goal>wsimport</goal> </goals> <configuration> <packageName>com.mycee.project.model</packageName> <wsdlFiles> <wsdlFile>${basedir}/src/jaxws/wsdl/wsdlb.wsdl</wsdlFile> </wsdlFiles> <bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory> <verbose>true</verbose> </configuration> </execution> </executions> </plugin> 
+11
source share

has a run item for each wsdl and puts the configuration into it. You can save common configuration items outside the run item. eg:.

 <build> <pluginManagement> <plugins> <plugin> <groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.1</version> <executions> <execution> <id>wsdla</id> <goals> <goal>wsimport</goal> </goals> <configuration> <wsdlFile> ${basedir}/src/jaxws/wsdl/wsdla.wsdl </wsdlFile> <sourceDestDir>target/gen/wsdla</sourceDestDir> </configuration> </execution> <execution> <id>wsdlb</id> <goals> <goal>wsimport</goal> </goals> <configuration> <wsdlFile> ${basedir}/src/jaxws/wsdl/wsdlb.wsdl </wsdlFile> <sourceDestDir>target/gen/wsdlb</sourceDestDir> </configuration> </execution> </executions> <configuration> <!-- Configure Output --> <packageName>com.mycee.project.model</packageName> <!-- Configure Binding Location --> <bindingDirectory> ${basedir}/src/jaxws/binding </bindingDirectory> <!-- Make Output Verbose --> <verbose>true</verbose> </configuration> </plugin> </plugins> </pluginManagement> 

Also, do not put the generated code in / main / src / java, as it does not clear.

+2
source share

All Articles