I have a pom file which is generating source from WSDL files which is designed something like this.
<executions>
<execution>
<id>Id1</id>
<goals>
<goal>wsimport</goal>
</goals>
开发者_StackOverflow社区<configuration>
<wsdlLocation>wsdl/HelloService.wsdl</wsdlLocation>
<wsdlFiles>
<wsdlFile>HelloService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>
${project.build.directory}/jaxws/stale/HelloService.wsdl.stale
</staleFile>
</configuration>
</execution>
<execution>
<id>Id2</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>wsdl/GoodByeService.wsdl</wsdlLocation>
<wsdlFiles>
<wsdlFile>GoodByeService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>
${project.build.directory}/jaxws/stale/GoodByeService.wsdl.stale
</staleFile>
</configuration>
</execution>
</executions>
<configuration>
<target>2.1</target>
<xjcArgs>
<xjcArg>-XautoNameResolution</xjcArg>
</xjcArgs>
<bindingDirectory>src/jaxws</bindingDirectory>
<keep>true</keep>
<wsdlDirectory>src/jaxws/wsdl</wsdlDirectory>
<packageName>com.test.hello.soap</packageName>
</configuration>
This is working really fine. And both the wsdl files are generated in the packageName (com.test.hello.soap
) but I want the wsdl file with Id2 to be generated in a separate packageName or location.
Can someone tell me how to do that please?
The <configuration>
tag at the bottom of your example defines config values that are common between the two executions.
If you want the value of <packageName>
to have one value for Id1 and another value for Id2, you simply need to move the <packageName>
config value into the <configuration>
block for each execution.
So, it looks like :
<executions>
<execution>
<id>Id1</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>wsdl/HelloService.wsdl</wsdlLocation>
<wsdlFiles>
<wsdlFile>HelloService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>
${project.build.directory}/jaxws/stale/HelloService.wsdl.stale
</staleFile>
<!-- packageName value for Id1 -->
<packageName>com.test.hello.soap</packageName>
</configuration>
</execution>
<execution>
<id>Id2</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>wsdl/GoodByeService.wsdl</wsdlLocation>
<wsdlFiles>
<wsdlFile>GoodByeService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>
${project.build.directory}/jaxws/stale/GoodByeService.wsdl.stale
</staleFile>
<!-- packageName value for Id2 -->
<packageName>com.test.goodbye.soap</packageName>
</configuration>
</execution>
</executions>
<configuration>
<target>2.1</target>
<xjcArgs>
<xjcArg>-XautoNameResolution</xjcArg>
</xjcArgs>
<bindingDirectory>src/jaxws</bindingDirectory>
<keep>true</keep>
<wsdlDirectory>src/jaxws/wsdl</wsdlDirectory>
<!-- packageName has been removed from here -->
</configuration>
I don't know the configuration to be made in pom.xml but the wsdl2java tool has a -p option that will allow you to specify the package for each namespace separately. The syntax is here
精彩评论