java WSDL for SOAP 和 WSDL for REST 和基于 JSON 的 REST
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5936380/
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
WSDL for SOAP and WSDL for REST and REST based on JSON
提问by ace
when a company wants to release a web services, does it release a separate WSDL for SOAP and separate for REST based web services or they are merged in the same WSDL? Can a WSDL only represent REST web services based on JSON (not XML) ?
当一家公司想要发布 Web 服务时,它是为 SOAP 发布单独的 WSDL,为基于 REST 的 Web 服务单独发布还是将它们合并到同一个 WSDL 中?WSDL 能否仅表示基于 JSON(而非 XML)的 REST Web 服务?
Assume web services clients are Java based.
假设 Web 服务客户端是基于 Java 的。
If SOAP and REST are merged in the same WSDL, does wsimport generates separate classes (for binding XML to Java objects) for SOAP and separate for REST?
如果 SOAP 和 REST 合并在同一个 WSDL 中,wsimport 是否为 SOAP 生成单独的类(用于将 XML 绑定到 Java 对象)并为 REST 生成单独的类?
采纳答案by Ladislav Mrnka
You need WSDL 2.0 (or WADL) to describe REST service. Support for WSDL 2.0 is currently very limited and wsimport doesn't support it. I'm not Java developer but I think that wsimport is only for SOAP services (JAX-WS and it doesn't support WSDL 2.0 as well).
您需要 WSDL 2.0(或 WADL)来描述 REST 服务。目前对 WSDL 2.0 的支持非常有限,wsimport 不支持。我不是 Java 开发人员,但我认为 wsimport 仅适用于 SOAP 服务(JAX-WS,它也不支持 WSDL 2.0)。
Edit:
编辑:
Check this extension. It should allow you exposing JAX-WS service with JSON encoding. It should also expose "JavaScript proxy" for calling the JSON service. To more precisely answer your question - I don't think that you can describe REST service without WSDL 2.0 or WADL. So you cannot merge SOAP and REST service to single WSDL 1.1 supported by most stacks. For further reference about describing JSON service check this question.
检查这个扩展。它应该允许您使用 JSON 编码公开 JAX-WS 服务。它还应该公开用于调用 JSON 服务的“JavaScript 代理”。为了更准确地回答您的问题 - 我认为您无法在没有 WSDL 2.0 或 WADL 的情况下描述 REST 服务。因此,您无法将 SOAP 和 REST 服务合并到大多数堆栈支持的单个 WSDL 1.1。有关描述 JSON 服务的进一步参考,请检查此问题。
回答by Qwerky
Can a WSDL only represent REST web services based on JSON (not XML)
WSDL 能否仅表示基于 JSON(而非 XML)的 REST Web 服务
WSDL 2 can describe XML by defining the XML types using a schema. See this introduction on WSDL 2 for REST.
WSDL 2 可以通过使用模式定义 XML 类型来描述 XML。请参阅有关 WSDL 2 for REST 的介绍。
Although, TBH I've never written WSDL for REST before, I just publish the URLs and the schemas for the types.
尽管 TBH 我以前从未为 REST 编写过 WSDL,但我只是发布了类型的 URL 和模式。
回答by Will Hartung
Since the tooling isn't quite there yet, I doubt many are using SOAP and HTTP bindings in a single WSDL. Although both can be represented in a WSDL 2.0, and at the same time, since most folks rely on tooling to manage their WSDLs today (and the rest of the WS stack), they probably simply don't bother and leave their WSDLs alone.
由于工具还没有完全成熟,我怀疑很多人是否在单个 WSDL 中使用 SOAP 和 HTTP 绑定。尽管两者都可以在 WSDL 2.0 中表示,但同时,由于今天大多数人依赖工具来管理他们的 WSDL(以及 WS 堆栈的其余部分),他们可能只是不打扰并且不理会他们的 WSDL。
Also, most REST people are building their clients by hand, rather than relying on tooling and WSDLs, so those folks aren't currently "missing" the tooling and support for this.
此外,大多数 REST 人员正在手工构建他们的客户端,而不是依赖工具和 WSDL,因此这些人目前并没有“缺少”对此的工具和支持。
When the tools catch up on both the server and client side, then there will likely be more adoption in practice for HTTP service bindings in WSDL 2.0. Whether the idiom will be to conflate the to specs in to a single WSDL or not, remains to be seen.
当这些工具在服务器端和客户端都迎头赶上时,WSDL 2.0 中的 HTTP 服务绑定可能会在实践中得到更多采用。习惯用法是否将规范合并到单个 WSDL 中,还有待观察。
If they want to host them on the same end points, then they likely will.
如果他们想在相同的端点上托管它们,那么他们很可能会这样做。