java 从 WSDL 自动生成 Web 服务 JAX-WS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15707538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 20:35:13  来源:igfitidea点击:

Auto-generate web-service JAX-WS from WSDL

javamavensoapwsdljax-ws

提问by user2225076

I have to create a web service equal to an existing one. The WSDL must be the same because they do not want to change the client. How can I do this?

我必须创建一个与现有服务相同的 Web 服务。WSDL 必须相同,因为它们不想更改客户端。我怎样才能做到这一点?

Also, how I can do with JAX-WS with Maven?

另外,我如何使用 Maven 使用 JAX-WS?

回答by Jops

Recreating a Web Service from WSDL

从 WSDL 重新创建 Web 服务

Based on the book, Java Web Services: Up and Running by Martin Kalin, one way to recreate a service from a WSDL is by starting at the client stubs.

根据Martin Kalin所著的Java Web 服务:启动和运行一书,从 WSDL 重新创建服务的一种方法是从客户端存根开始。

wsimport -keep -p <your wsdl>

The item of interest will be the generated SEI code.

感兴趣的项目将是生成的 SEI 代码

You can remove the client-specific annotations, replace them with server-side annotations and use this as your base interface when rebuilding the web service.

您可以删除特定于客户端的注释,将其替换为服务器端注释,并在重建 Web 服务时将其用作基本界面。

With the SEI at your disposal, you can easily create your own SIB and publish it.

使用 SEI,您可以轻松创建自己的 SIB 并发布。

Important Note:Of course, you will notsee the logic behind their SIB, that will not be available to you at any point. But the above approach will hopefully be useful for you since you want to create your own implementation anyway.

重要提示:当然,您不会看到他们的 SIB 背后的逻辑,您在任何时候都无法使用这些逻辑。但是上述方法希望对您有用,因为您无论如何都想创建自己的实现。

JAX-WS with Maven

带有 Maven 的 JAX-WS

This deserves a separate question on its own. Maven has a jax-ws plugin (artifact ID: jaxws-maven-plugin) for you to start with. More info at this link: Using JAX-WS with Maven.

这本身就值得一个单独的问题。Maven 有一个 jax-ws 插件(工件 ID:jaxws-maven-plugin)供您开始使用。此链接中的更多信息:将 JAX-WS 与 Maven 结合使用