如何从 Pom.xml 中的 WSDL 生成 Java 源代码?

发布于 2024-10-19 13:04:15 字数 1877 浏览 4 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不美如何 2024-10-26 13:04:15

示例底部的 标记定义了两次执行之间通用的配置值。

如果您希望 的值具有一个 Id1 值和另一个 Id2 值,则只需将 配置值移至每次执行的 块。

所以,它看起来像:

<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>

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>
还在原地等你 2024-10-26 13:04:15

我不知道要在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文