如何用java编写有效的Web服务

发布于 2024-09-01 14:27:25 字数 344 浏览 5 评论 0原文

虽然这可能看起来与 Java Web Services 重复,但我想知道在哪里开始并继续。过去,我投入了很多时间来寻找从哪里开始,但我无法做到。在阅读有关 Web 服务的页面时,有很多行话和混乱(至少对我来说!)。有很多术语 - 例如 JAX-RPC、JAX-WS、Axis、Rest、Servlet as WebService、EJB's as Web Service 以及其他我不知道的术语。该用户组能否整合并提供易于理解和遵循的 Java Web 服务的高级概述?我感谢您的好意并感谢您的帮助。

Though this might appear as a duplicate of Java Web Services , I would like to know Where to start and to continue.In the past, I have invested so much of time to find where to start but I wasn't able to. There are so many jargons and chaos (at least for me!) while reading the pages about web services. There are so many terms - like JAX-RPC, JAX-WS, Axis, Rest, Servlet as WebService, EJB's as Web Service and other terms that I don't know. Can this User group consolidate and give a highlevel overview of Java Web Services which is easy to understand and follow? I appreciate your kindness and thanks for your help.

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

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

发布评论

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

评论(2

旧人 2024-09-08 14:27:25

对于理解 Web 服务来说,这确实有点像丛林。 wikipedia 页面不错,但仍然缺少一些元素。

我已将此答案标记为社区维基,因此请随时更新或更正它。这只是一个基础。

一个臃肿的术语:

首先,术语网络服务用于指代许多事物。虽然许多人用它来指代基于 SOAP 的 Web 服务,但该术语可用于表示通过 Web 界面提供的任何服务;这是造成混乱的一个根源。

实现和设计风格:

  • 基于 SOAP——SOAP 仍然是 Web 服务事实上的标准。 SOAP 是 HTTP 之上的协议,描述消息和异常的交换。随着后来添加的所有 WS-* 标准,SOAP 从简单的东西发展到非常复杂的东西。最重要的是:WS-Policy、WS-Security、WS-Addressing、WS-Transaction。另一个重要的规范是用于大消息的 MTOM。
  • RESTful——术语RESTful涉及以下事实:服务是无状态的,并且所有相关信息都作为参数传递。此外,我们不使用 SOAP 之类的协议,而是使用普通的 HTTP 动词,例如 GetPutDelete更新
  • 无状态——WS通常是无状态的。处理的业务有时依赖于所谓的相关标识符(带有 WS-Addressing),用于将请求和响应匹配在一起;这与在 cookie 中存储会话标识符的想法相同,因为 HTTP 是无状态的。
  • 有状态——有一些关于有状态WS的建议,但我对此了解不多。

实现和技术堆栈:

  • Servlet——实现 WS 的最低级别方法:您基本上自己解析请求并吐出 HTTP 响应。
  • EJB——从EJB3开始,EJB可以很容易地作为Web服务公开。当然需要 EJB 容器。
  • Apache Axis——曾经是一种流行的技术堆栈,但现在正在衰落。
  • Apache CXF——另一个流行的选择。
  • JBossWS——另一个流行的选择。
  • JAX-WS -- Sun 的官方 Web 服务堆栈,非常好。到目前为止,我知道,这个 取代了 JAX-RPC,后者被简单地重命名为 JAX-WS。

相关概念和术语:

  • WSDL —— 在基于 SOAP 的 WS 情况下,定义 Web 服务的契约/接口。
  • 合同优先——指的是一项技术能够支持任何预先提供的 WSDL。与基于 Web 服务的实现生成 WSDL 的实现技术相反,在这种情况下,WSDL 不能总是根据需要进行定制
  • 配置文件 - 为了简化这种混乱,他们'我们引入了配置文件,这些配置文件是需要支持互操作性的相关规范/功能组。主要的是WS-I Basic Profile。
  • UDDI 和发现——似乎有些人认为 Web 服务将在公共寄存器中发布,以便潜在消费者可以发现。我认为这个愿景并没有获得太大的推动力。

That's indeed a bit a jungle to understand web services. The wikipedia page is decent, but still lacks some elements.

I've flagged this answer as community wiki, so feel free to update it, or correct it. It's only a basis.

A bloated term:

First, the term web service is used to refer to many thing. While many people use it to refer to SOAP-based web service, the term can be used to denote any service provided through a web interface; this is a source of confusion.

Implementation and design style:

  • SOAP-based -- SOAP is still the de-facto standard for web services. SOAP is protocol on top of HTTP that describes the exchange of message and exception. SOAP grew from something simple to something very complicated with all the WS-* standards that have been added later. The most important are: WS-Policy, WS-Security, WS-Addressing, WS-Transaction. Another important spec is MTOM for large message.
  • RESTful -- The term RESTful relates to the fact that the service is stateless and all relevant information is passed as parameter. Also instead of using a protocol like SOAP, plain HTTP verbs are used, e.g. Get, Put, Delete, Update.
  • Stateless -- WS are usually stateless. Business processed sometimes rely on so-called correlation identifiers (with WS-Addressing) that are used to match requests and response together; this is the same idea like storing a session identifier in a cookie because HTTP is stateless.
  • Stateful -- There are some proposal to have stateful WS, but I don't know much about it.

Implementation and technology stacks:

  • Servlet -- The lowest-level way to implement a WS: you basically parse the request and spit the HTTP response all by yourself.
  • EJB -- Since EJB3, EJB can be exposed as web service very easily. Needs an EJB container, of course.
  • Apache Axis -- Used to be a popular technology stack which is declining now.
  • Apache CXF -- Another popular choice.
  • JBossWS -- Yet another popluar choice.
  • JAX-WS -- The official web service stack from Sun, very good. So far I know, this replaces JAX-RPC which was simply renamed JAX-WS.

Related concepts and jargon:

  • WSDL -- Defines the contract/interface of the web service, in case of SOAP-based WS.
  • Contract-first -- Refers to the fact that that a technology is able to support any WSDL provided upfront. On the contrary to an implementation technology which will generate the WSDL based on the implementation of the web service, in which case the WSDL can not always be customized as necessary
  • Profile -- To simplify this mess, they've introduced profiles which are groups of related specifications/capabilities that need to be supported for interoperability. The main one is WS-I Basic Profile.
  • UDDI and discovery -- It seems like some people thought the web service would be published in a public register so as to be discoverable by potential consumer. I don't think this vision gained much momentum.
寒冷纷飞旳雪 2024-09-08 14:27:25

我所知道的“合同优先”网络服务的最佳解释是 Spring Web服务模块

The best explanation I know for "contract first" web services is Spring web service module.

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