使用 XML 目录从 WSDL 生成代码

发布于 2024-08-20 03:10:56 字数 329 浏览 6 评论 0原文

是否有任何工具可以使用 XML 目录从 WSDL 生成 Java 代码?问题是我有导入 XML 架构的 wsdl 文件,这些文件还导入其他架构,并且这些架构在 schemaLocation url 处不可用。这就是代码生成失败的原因。如果工具能够使用 XML Catalog,则无需修改每个 WSDL 和模式中的每个 schemaLocation 即可解决此问题。

我尝试过 Eclipse 和 Netbeans 插件,但都失败了。在 Eclipse 和 Netbeans 中,我使用 XML Catalog 配置了替代架构位置,因此它们可以验证 WSDL 文件而不会出现错误。然而,当他们从 wsdl 生成代码时,他们会失败。

Is there any tool for generating Java code from WSDL using XML Catalogs? The problem is that I have wsdl files that import XML schemas which also import other schemas and the schemas are not available at schemaLocation url. That is why code generation fails. If a tool was able to use XML Catalog this problem would be solved without modifying each schemaLocation in each WSDLs and schemas.

I have tried Eclipse and Netbeans plugins but both failed. In Eclipse and Netbeans I have configured alternative schema locations by using XML Catalog and so they can validate WSDL files without error. However, when they generate code from wsdl they fail.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

云雾 2024-08-27 03:10:56

刚刚发现 JBoss 的 wsconsume 工具能够使用 XML 目录进行实体解析,并且工作正常。

http://community.jboss.org/wiki/JBossWS-wsconsume

Just found that JBoss's wsconsume tool is able to consume XML Catalogs for entity resolution and it works fine.

http://community.jboss.org/wiki/JBossWS-wsconsume

时光暖心i 2024-08-27 03:10:56

仅供记录:我在 Github 上建立了一个使用 XML 模式的小示例项目。它可能有任何帮助: https://github.com/fmarot/xml-mapping-tutorial< /a>
请务必检查其 wiki 以获得概述:
https://github.com /fmarot/xml-mapping-tutorial/wiki

Just for the record: i've set up a small exemple project on Github that uses an XML schema. it may be of any help: https://github.com/fmarot/xml-mapping-tutorial
Be sure to check its wiki too in order to have an overview: https://github.com/fmarot/xml-mapping-tutorial/wiki

一萌ing 2024-08-27 03:10:56

WSDL 必须在不使用 XML 目录的情况下有效,否则使用该 WSDL 的客户端将无法使用它。

当然,如果您永远不会使用任何不在 JBoss 平台上运行的客户端,那么您会没事的。

The WSDL has to be valid without the use of XML catalogs, or clients consuming that WSDL will not be able to consume it.

Of course, if you will never use any clients not running on the JBoss platform, then you'll be fine.

‘画卷フ 2024-08-27 03:10:56

与此同时,我找到了另一种最适合我需求的解决方案。有一个名为 jaxws-maven-plugin 的 Maven 插件,它还能够在从 wsdl 生成源时处理 XMLCatalogs。

https://jax-ws-commons.dev.java.net /jaxws-maven-plugin/

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
    <execution>
        <id>id1</id>
        <phase>generate-sources</phase>
        <goals>
            <goal>wsimport</goal>
        </goals>
        <configuration>
            <verbose>true</verbose>
            <keep>true</keep>
            <catalog>${basedir}/src/main/resources/catalog.xml</catalog>
            <packageName>org.example</packageName>
            <wsdlDirectory>
                ${basedir}/src/main/resources/contracts/wsdl/ExampleService/1
            </wsdlDirectory>
            <wsdlFiles>
                <wsdlFile>ExampleService_1_0.wsdl</wsdlFile>
            </wsdlFiles>
            <xadditionalHeaders>false</xadditionalHeaders>
        </configuration>
    </execution>
</executions>
<configuration>
</configuration>
<dependencies>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-tools</artifactId>
        <version>2.1.7</version>
    </dependency>
</dependencies>

Meanwhile, I found an other solution that fits the best to my needs. There is a maven plugin called jaxws-maven-plugin that is also able to handle XMLCatalogs when generating sources from wsdl.

https://jax-ws-commons.dev.java.net/jaxws-maven-plugin/

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
    <execution>
        <id>id1</id>
        <phase>generate-sources</phase>
        <goals>
            <goal>wsimport</goal>
        </goals>
        <configuration>
            <verbose>true</verbose>
            <keep>true</keep>
            <catalog>${basedir}/src/main/resources/catalog.xml</catalog>
            <packageName>org.example</packageName>
            <wsdlDirectory>
                ${basedir}/src/main/resources/contracts/wsdl/ExampleService/1
            </wsdlDirectory>
            <wsdlFiles>
                <wsdlFile>ExampleService_1_0.wsdl</wsdlFile>
            </wsdlFiles>
            <xadditionalHeaders>false</xadditionalHeaders>
        </configuration>
    </execution>
</executions>
<configuration>
</configuration>
<dependencies>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-tools</artifactId>
        <version>2.1.7</version>
    </dependency>
</dependencies>

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