如何从使用现有 XSD 类型的 WSDL 构建 Java

发布于 12-27 17:00 字数 237 浏览 1 评论 0原文

我正在尝试创建一个使用现有类型的新网络服务。这些类型是在我们从第三方收到的现有 XSD 以及匹配的 JAR 文件中定义的。如果我只是将该 XSD 导入到 WSDL 中并构建 Java(使用 wsconsume),那么也会构建所有现有类型。由于我们已经有一个包含所有这些 Java 类型的 JAR,因此我们不想再次生成它们。

作为后备选项,我可以让 ant 删除这些冗余文件,但我宁愿找到一种方法来首先不生成它们。

有什么建议吗?

I'm trying to create a new web service that uses existing types. The types are defined in an existing XSD that we received, along with a matching JAR file, from a third party. If I just import that XSD into my WSDL and build the Java (using wsconsume), then all the existing types are also built. Since we already have a JAR that contains all these Java types, we don't want to generate them again.

As a fallback option I can have ant delete these redundant files, but I'd rather find a way to not generate them in the first place.

Any suggestions?

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

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

发布评论

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

评论(1

不…忘初心2025-01-03 17:00:49

我的建议是使用 Spring WebServices 它应该可以帮助您实现这样的实现,它

  • 契约优先的原则,其中契约是XSD而不是WSDL,
  • 允许您编写带有例如@PayloadRoot注释的方法的@Endpoint类并使用JAR 中的类型参数您拥有的
  • 允许您使用 生成 WSDL

如果您拥有的 JAR 具有带有 JAXB 注释的类,那么您可以直接使用 JAXB,如果没有 - 您始终可以使用其他绑定技术。

My suggestion is to use Spring WebServices which should help you with such implementation, it:

  • has a principle of contract first where the contract is rather XSD than WSDL
  • allows you to write @Endpoint class with methods annotated with e.g. @PayloadRoot and using parameters of types from the JAR you've got
  • allows you to generate WSDL with <sws:dynamic-wsdl />

If the JAR you've got has classes with JAXB annotations then you can use JAXB directly, if not - you can alway use other binding technologies.

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