如何在java中编写有效的Web服务 [英] How to write effective web services in java

查看:126
本文介绍了如何在java中编写有效的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然这可能与 Java Web Services 重复,但我希望知道从哪里开始和继续。过去,我花了很多时间来寻找从哪里开始,但我无法做到。在阅读有关Web服务的页面时,有这么多的术语和混乱(至少对我而言!)。有很多术语 - 比如 JAX-RPC,JAX-WS,Axis,Rest,Servlet作为WebService,EJB的作为Web服务和其他我不知道的术语。该用户组是否可以整合并提供易于理解和遵循的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.

推荐答案

这对于理解网络服务来说确实是一个丛林。 维基百科页面很不错,但仍缺少一些元素。

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.

一个臃肿的术语:

首先,术语 web服务用于指代很多东西。虽然许多人使用它来引用基于SOAP的Web服务,但该术语可用于表示通过Web界面提供的任何服务;这是混乱的根源。

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.

实施和设计风格:


  • 基于SOAP的 - SOAP仍然是Web服务的事实标准。 SOAP是HTTP之上的协议,用于描述消息和异常的交换。随着所有 WS- *标准之后添加的SOAP从简单的东西变成了非常复杂的东西。最重要的是:WS-Policy,WS-Security,WS-Addressing,WS-Transaction。另一个重要的规格是针对大型消息的MTOM。

  • RESTful - 术语 RESTful 涉及服务是无状态的事实所有相关信息都作为参数传递。此外,不使用像SOAP这样的协议,而是使用普通的HTTP 动词,例如, 获取 Put 删除更新

  • 无状态 - WS通常是无状态的。处理的业务有时依赖于所谓的相关标识符(使用WS-Addressing),用于将请求和响应一起匹配;这就像将会话标识符存储在cookie中一样,因为HTTP是无状态的。

  • 有状态 - 有一些建议要有状态WS,但我不太了解它。

  • 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.

实施和技术堆栈:


  • Servlet - 实现WS的最低级别方式:您基本上解析请求并自己发送HTTP响应。

  • EJB - 从EJB3开始,EJB可以非常容易地作为Web服务公开。当然需要一个EJB容器。

  • Apache Axis - 曾经是一个流行的技术堆栈,现在正在下降。

  • Apache CXF - 另一个受欢迎的选择。

  • JBossWS - 又一个流行的选择。

  • JAX-WS - 来自Sun的官方Web服务堆栈,非常好。到目前为止,我知道,这个取代了 JAX-RPC,它简称为JAX-WS。

  • 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.

相关概念和行话:


  • WSDL - 在基于SOAP的WS的情况下定义Web服务的合同/接口。

  • 合同优先 - 指的是事实上,技术能够支持任何提前提供的WSDL。与将基于Web服务的实现生成WSDL的实现技术相反,在这种情况下,WSDL不能总是根据需要进行自定义

  • Profile - 为了简化这种混乱,他们引入了配置文件,这些配置文件是需要支持互操作性的相关规范/功能组。主要的是WS-I Basic Profile。

  • UDDI和发现 - 似乎有些人认为Web服务将在公共注册中发布所以至于潜在消费者可以发现的。我不认为这个愿景获得了很大的动力。

  • 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.

这篇关于如何在java中编写有效的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆