为什么JAX-WS是JDK的一部分而JAX-RS不是? [英] Why is JAX-WS part of the JDK but JAX-RS is not?

查看:204
本文介绍了为什么JAX-WS是JDK的一部分而JAX-RS不是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Eclipse时,我可以使用JAX-WS注释(例如@WebService)而不包含任何外部依赖项,但我不能对JAX-RS注释(例如@Path)执行相同的操作。我看了一下这个的答案,我知道javax.ws.rs不是JDK的一部分。为什么JAX-WS是JDK的一部分而JAX-RS不是?
其次,如果我在GlassFish或WildFly服务器上部署JAX-WS带注释的应用程序,服务器是否使用众所周知的WebService堆栈来运行应用程序(例如Metro)或其自己的实现?

When using Eclipse, I'm able to use JAX-WS annotations (e.g. @WebService) without including any external dependencies, but I can't do the same for JAX-RS annotations (e.g. @Path). I took a look at this answer and I understand that javax.ws.rs is not a part of the JDK. Why is it that JAX-WS is part of the JDK and JAX-RS is not? Secondly, if I deploy a JAX-WS annotated application on a GlassFish or WildFly server, does the server use a well known WebService stack to run the application (e.g. Metro) or its own implementation?

推荐答案

JAX-WS:用于XML Web服务的Java API



让我们回到2006年。 Java SE 6发布时引入了许多新功能。

JAX-WS: Java API for XML Web Services

Let's go back to 2006. Java SE 6 was released introducing lot of new features.

引用Java SE 6规范( JSR 270 ),关于Java SE 6中引入的功能:

Quoting the Java SE 6 specification (JSR 270), about the features introduced in Java SE 6:


Java SE 6的功能集在很大程度上是由一组主题驱动的。

The feature set for Java SE 6 is driven, in large part, by a set of themes.

这些主题描述了该版本的主要焦点。有些主题是相当抽象的指导原则;其他更具体的是,它们确定了特定的问题区域,重要的新功能集或特定的目标细分市场。

The themes describe the main focal points of the release. Some themes are fairly abstract guiding principles; others are more concrete in that they identify particular problem areas, significant new feature sets, or specific target market segments.

[...]


  • XML& Web服务:最初提出的Java SE 5版本旨在包含完整的Web服务客户端堆栈。遗憾的是,这项工作无法在该版本及时完成,与此同时,XML和Web服务的重要性只会增加到社区的许多成员。

  • XML & Web Services: The Java SE 5 release, as originally proposed, was intended to include a full Web Services client stack. That work unfortunately could not be completed in time for that release, and in the meantime XML and Web Services have only increased in their importance to many members of the community.

[...]

JAX-WS 2.0规范的目标之一是准备JAX -WS包含在未来版本的J2SE中(稍后重命名为 Java SE )。引用 JSR 224

One of the goals of the JAX-WS 2.0 specification was to prepare JAX-WS for inclusion in a future version of J2SE (that was renamed to Java SE later). Quoting the JSR 224:



  • 包含在J2SE中:JAX-WS 2.0将准备JAX-WS以包含在J2SE的未来版本中。应用程序可移植性是一项关键要求,JAX-WS 2.0将定义生成完全可移植客户端的机制。

  • Inclusion in J2SE: JAX-WS 2.0 will prepare JAX-WS for inclusion in a future version of J2SE. Application portability is a key requirement and JAX-WS 2.0 will define mechanisms to produce fully portable clients.

Java SE 6包含JAX-WS 2.0组件,介绍了在Java SE中创建基于SOAP的Web服务的可能性。从Oracle引用这篇文章

Java SE 6 included the JAX-WS 2.0 component, introducing the possibility of creating SOAP based web services in Java SE. Quoting this article from Oracle:


Java平台最令人兴奋的新功能之一,标准版6(Java SE 6)是对XML Web Services的Java API的支持(JAX-WS),版本2.0。 JAX-WS 2.0是用于Web服务的新重新架构API堆栈的中心。

One of the most exciting new features of the Java Platform, Standard Edition 6 (Java SE 6) is support for the Java API for XML Web Services (JAX-WS), version 2.0. JAX-WS 2.0 is the center of a newly rearchitected API stack for web services [...].

尽管JAX-WS在开源中找到了它的主要内容Java平台企业版5(Java EE 5)的世界,旨在取代Java API for XML-Based RPC(JAX-RPC),在这样的环境中,您可以重用大部分功能而无需触及企业服务器[...]

Although JAX-WS finds its main home in the open-source world of the Java Platform, Enterprise Edition 5 (Java EE 5) and is designed to take the place of Java API for XML-Based RPC (JAX-RPC) in such an environment, you can reuse much of the functionality without even touching an enterprise server [...]

您可以使用JAX-WS构建Web应用程序和Web服务,并结合使用较新的基于XML的Web服务功能。 [...]

You can use JAX-WS to build web applications and web services, incorporating the newer XML-based web services functionality. [...]

运行应用程序时,Java SE 6平台有一个小型Web应用程序服务器,可以发布Web服务。 [...]

When you run the application, the Java SE 6 platform has a small web application server that will publish the web service. [...]



JAX-RS:用于RESTful Web服务的Java API



JAX-RS于2008年推出。它最初是由 JSR 311定义的。 它包含在Java EE 6总体规范中( JSR 316 )。

JAX-RS: Java API for RESTful Web Services

JAX-RS came later, in 2008. It was initially defined by the JSR 311 and it was included under the Java EE 6 umbrella specification (JSR 316).

JAX-RS的第二个版本于2013年推出,由 JSR 339 ,它包含在Java EE 7保护伞规范中( JSR 342 )。

The second version of JAX-RS came in 2013, defined by the JSR 339 and it was included under the Java EE 7 umbrella specification (JSR 342).

JAX-RS是以HTTP为中心的,JAX-RS应用程序经常部署在servlet容器上。

JAX-RS is HTTP centric and JAX-RS applications are frequently deployed on servlet containers.

Java SE 7( JSR 336 )和Java SE 8( JSR 337 )规范不包含JAX-RS组件。但是,JAX-RS应用程序可以在Java SE环境中发布(使用 RuntimeDelegate )和JAX-RS实现也可以支持通过JAX-WS发布。

The Java SE 7 (JSR 336) and the Java SE 8 (JSR 337) specifications don't incorporate the JAX-RS component. However, JAX-RS applications can be published in Java SE environments (using RuntimeDelegate) and JAX-RS implementations also may support publication via JAX-WS.

在Java SE中包含JAX-RS还意味着包含该规范的实现。它使Java SE环境中的事情变得更加复杂,但在容器为您提供实现的Java EE环境中完全可以接受。例如,GlassFish为您提供Jersey(参考实现),而JBoss / WildFly为您提供RESTEasy。

Including JAX-RS in Java SE also means including an implementation for that specification. And it makes things more complicated in the Java SE environment, but perfectly acceptable in a Java EE environment where your container will provide you an implementation. For example, GlassFish gives you Jersey (the reference implementation) while JBoss/WildFly gives you RESTEasy.

这篇关于为什么JAX-WS是JDK的一部分而JAX-RS不是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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