如何从 Pom.xml 中的 WSDL 生成 Java 源代码?
我有一个 pom 文件,它从 WSDL 文件生成源代码,其设计如下。
<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>
</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>
这工作得很好。这两个 wsdl 文件都是在 packageName (com.test.hello.soap
) 中生成的,但我希望在单独的 packageName 或位置中生成 Id2 的 wsdl 文件。
有人可以告诉我该怎么做吗?
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>
<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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
示例底部的
标记定义了两次执行之间通用的配置值。如果您希望
的值具有一个 Id1 值和另一个 Id2 值,则只需将
配置值移至每次执行的
块。所以,它看起来像:
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 :
我不知道要在 pom.xml 中进行的配置,但 wsdl2java 工具有一个 -p 选项,允许您分别为每个命名空间指定包。语法是这里
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