REST Web 服务 WSDL?

发布于 2024-11-26 09:58:17 字数 157 浏览 1 评论 0原文

我正在实现一个 Web 服务,并且已经实现了 REST 和 SOAP 版本,看看哪个版本适合我的需求。我决定选择 REST,因为它很简单,而且我可能会开发一个 iPhone 应用程序来使用它。我的问题很简单,是否可以为我的 REST 服务创建 WSDL 或 WADL?有必要吗?

谢谢

I am implementing a web service and I have implemented both a REST and SOAP version to see which suited my needs.I have decided to choose REST because of its simplicity and that I will probably be developing an iPhone app to consume it. My question is simple really, is it possible to create a WSDL or WADL for my REST service and is it necessary?

Thanks

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

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

发布评论

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

评论(7

浮生未歇 2024-12-03 09:58:17

有了良好的 RESTful 服务,就没有必要为其生成 WADL(更不用说不太合适的 WSDL)了,因为它会自我描述。我所说的“自我描述”具体是指它将提供描述服务发布的所有(相关)资源的文档,并且对其中任何资源使用标准 HTTP OPTIONS 请求将生成有关如何交互的基本信息。使用 WADL 的唯一真正好处是它允许调用者提前发现需要处理的复杂文档的模式; REST 本身并没有提供任何帮助(一些 RESTians 认为这样做会适得其反,我不确定我是否同意)。

当然,这并没有捕获更深层的交互模式,但绝大多数服务的 WSDL 描述也没有捕获到,因此没有任何变化。


作为记录,我使用 Apache CXF 创建 RESTful 服务(使用 JAX-RS)并为它们发布 WADL。

With a good RESTful service, it's not necessary to generate WADL (let alone the much-less-well-fitting WSDL) for it because it will self-describe. By “self-describe” I specifically mean that it will deliver documents describing all the (relevant) resources published by the service, and that using a standard HTTP OPTIONS request on any of these will produce basic information about how to interact. The only real benefit to using WADL is that it allows the caller to discover the schemas for the complex documents it needs to work with ahead of time; REST itself provides no help there (and some RESTians believe that doing such things is counter-productive, which I'm not sure I agree with).

Of course, that doesn't capture the deeper interaction patterns, but neither do the vast majority of WSDL descriptions of services so no change there.


For the record, I use Apache CXF to create RESTful services (using JAX-RS) and that publishes WADL for them.

櫻之舞 2024-12-03 09:58:17

W3C 已正式建议 REST 文档标准基于 [WSDL 2.0][3]。以下是 IBM 文章中的引用:

术语“Web 服务”通常与操作或
使用 SOAP 和 WS* 标准的基于操作的服务,例如
WS 寻址和 WS 安全。术语 REST Web 服务通常
指的是使用 HTTP 的基于资源的 Web 服务架构
和XML。这些架构 Web 服务风格中的每一种都有其自己的位置,
但直到最近,WSDL 标准还没有同等支持这两者
风格。 WSDL 1.1 HTTP 绑定不足以描述
使用 HTTP 和 XML 进行通信,因此无法正式
使用 WSDL 描述 REST Web 服务。 WSDL 2.0的发布,
它的设计考虑了 REST Web 服务,作为万维网
联盟 (W3C) 推荐意味着现在有一种语言可以
描述 REST Web 服务。

The W3C has made a formal recommendation for a REST documentation standard based on [WSDL 2.0][3]. Here is a quote from the IBM article:

The term Web services is typically associated with operation- or
action-based services using SOAP and the WS* standards, such as
WS-Addressing and WS-Security. The term REST Web services generally
refers to a resource-based Web services architecture that uses HTTP
and XML. Each of these architectural Web service styles has its place,
but until recently, the WSDL standard didn't equally support both
styles. The WSDL 1.1 HTTP binding was inadequate to describe
communications with HTTP and XML, so there was no way to formally
describe REST Web services with WSDL. The publication of WSDL 2.0,
which was designed with REST Web services in mind, as a World Wide Web
Consortium (W3C) recommendation means there is now a language to
describe REST Web services.

甜味超标? 2024-12-03 09:58:17

正如 @GiuliaDiFederico 所说,“当然这是可能的”(使用 WSDL2),显示了关于如何操作的良好源链接。另一方面,@DonalFellows 并不鼓励使用 WSDL...

我认为 WSDL 的使用是一个问题

  • 形式化级别:使用 WSDL,您可以表达更多内容正式您的网络服务的所有相关详细信息。
  • 稳定性水平:如果您需要长期合同,并避免 Web 服务暴露的环境发生变化的风险,WSDL 有助于保持稳定性。
  • 需要标准:如果客户更喜欢可以说“符合标准”的网络服务,请使用标准。唯一的就是W3C,而W3C 需要XML、SOAP 和WSDL。

As @GiuliaDiFederico said, "of course it's possible" (with WSDL2), showing a good source link about how to do. @DonalFellows, by other hand, does not encouraged the use of WSDL...

I think the use of WSDL is a question of

  • FORMALIZATION LEVEL: with WSDL you can express more formally all relevant details of your webservice.
  • STABILITY LEVEL: if you need long term contracts, and avoid risks of changes in the enviroment where your webservice is exposed, WSDL helps to mantain stability.
  • NEED FOR STANDARDS: if customers prefer webservices that can be said "standard compliant", use standards. The only one is W3C, and W3C requires XML, SOAP and WSDL.
蒲公英的约定 2024-12-03 09:58:17

RestDoc 尝试为 REST 资源创建一个简单的文档框架。
可以通过restdoc-renderer使用浏览器。

它还提供 Java 注释启用 RestDoc 文档的即时创建。实现可用于 Jersey 1.xJAX-RS 2.0

RestDoc tries to create a simple documentation framework for REST resources.
A browser is available via restdoc-renderer.

It also offers Java annotations to enable on-the-fly creation of RestDoc documetnation. Implementations are available for Jersey 1.x and JAX-RS 2.0.

北斗星光 2024-12-03 09:58:17

当然有可能,但是为了回答是否有必要,您没有提供足够的信息。

我建议您查看 ibm 的developerworks 网站,该网站提供了一个有趣的 关于主题的文章


严格来说,使用 WSDL 1.0 您不能,但是使用 WSDL2 就可以,因为它就是为了接受这种需求而开发的,

“... WS-I 配置文件中的 WSDL 2.0 满足了这些要求
用于 REST 风格的 Web 服务。 SOAP 1.2 中添加的 GET 等
WSDL 2.0 中的附加内容,例如操作安全性、描述能力
引用其他 Web 服务的消息以及改进的 HTTP 绑定
现在可以描述 REST 风格的 Web 服务。", 阿瑟·莱曼

Of course it's possible, but for answer if it is necessary or not, you didn't provide enough info.

I suggest you to take a look on the ibm's developerworks site that provide an interesting article on subject


Strictly, with WSDL 1.0 you can' t, but with WSDL2 you can, because was developed for accept this kind of demand,

"... WSDL 2.0 in a WS-I profile that addressed the requirements
for REST style Web services. The addition of GET in SOAP 1.2 and several
additions in WSDL 2.0 such as operation safety, the ability to describe
messages that refer to other Web services, and the improved HTTP binding
now make it possible to describe REST style Web services.", Arthur Ryman.

野生奥特曼 2024-12-03 09:58:17

我认为 WSDL 不适合 REST,WADL 也没有必要。 HTTP 已经公开了 WADL 可以在单独的文件中描述的内容。例如,“Allow”标头返回允许的 HTTP 方法,而内容协商用于选择正确的格式。

I think WSDL is not appropriate for REST and WADL is not necessary. HTTP exposes already what WADL could describe in a separate file. For example the "Allow" header returns allowed HTTP method, and Content Negotiation is for choosing the right format.

我只土不豪 2024-12-03 09:58:17

WADL 不是必需的。但是,如果应用程序中已存在客户端代码,并且您想要进行新的其余调用,那么最好使用 wadl 生成客户端 java 存根 (POJO)。通过这种方式,客户端 POJO 将与服务端 POJO 同步。例如,如果您要在现有应用程序中用 Rest 服务调用替换 EJB/SOAP 服务调用,那么使用 WADL 是非常安全且良好的做法。

您可以使用 wadl2java maven 插件从 WADL 生成客户端 java 存根。

WADL is not necessary. But, If Client side code is already present in an application and you want to make a new rest call then it is good practice that you use wadl for generating the client side java stub(POJO). By this way, client side POJOs will be in sync with service side POJOs. For example, If you are replacing EJB/SOAP service call with Rest service call in an existing application then It is very safe and good practice to use WADL.

You can generate client side java stubs from WADL by using wadl2java maven plugin.

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