Why is JAX-WS part of the JDK but no JAX-RS?

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

+4
source share
2 answers

JAX-WS: Java API for XML Web Services

Let's get back to 2006. Java SE 6 has been released, introducing many new features.

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

The feature set for Java SE 6 is largely determined by the topic set.

Themes describe the main topics of the release. Some topics are pretty abstract guidelines; others are more specific in that they identify specific problem areas, significant new feature sets, or specific target market segments.

[...]

  • XML & Web Services: The Java SE 5 release, as originally proposed, was supposed to include a full stack of web service clients. Unfortunately, this work cannot be completed in time for this release, and meanwhile their value for XML and web services has only increased for many members of the community.

[...]

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

  • J2SE inclusion: 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 identify mechanisms for creating fully portable clients.

Java SE 6 included the JAX-WS 2.0 component, which provides the ability to create SOAP-based web services in Java SE. I quote this article from Oracle:

One of the most interesting new features of the Java Standard Edition 6 platform (Java SE 6) is Java API Support for XML Web Services (JAX-WS) version 2.0. JAX-WS 2.0 is the center of the recently redesigned API stack for web services [...].

Although JAX-WS is located in the Java open source world, Enterprise Edition 5 (Java EE 5) is designed to replace the Java API for XML-based RPC (JAX-RPC) in such an environment, you can use most of the functionality without even touching the corporate server [...]

You can use JAX-WS to create web applications and web services that incorporate new XML-based web service functionality. [...]

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

JAX-RS: Java API for RESTful Web Services

JAX-RS appeared later in 2008. It was originally defined by JSR 311 and is included in the Java EE 6 General Specification ( JSR 316 ).

The second version of JAX-RS was released in 2013 and was defined by JSR 339 and is included in the Java EE 7 General Specification ( JSR 342 ).

JAX-RS is HTTP oriented, and JAX-RS applications are often deployed in servlet containers.

The Java SE 7 ( JSR 336 ) and Java SE 8 ( JSR 337 ) specifications do not include the JAX-RS component. However, JAX-RS applications can be published in Java SE environments (using RuntimeDelegate ), and JAX-RS implementations can also support publishing through JAX-WS.

The inclusion of JAX-RS in Java SE also means the inclusion of an implementation for this specification. And this complicates the situation in the Java SE environment, but is perfectly acceptable in the Java EE environment, where your container will provide you with an implementation. For example, GlassFish gives you Jersey (reference implementation), and JBoss / WildFly gives you RESTEasy.

+5
source

JAX-RS (Java API for RESTful Web Services) is actually a specification that defines REST support. The specification is defined through a Java Specification Request (JSR) 311.

In a nutshell, this specification defines the API and some annotations that all compatible JAX-RS implementations should use. Thus, the specification itself is used by JAX-RS developers who create a JAX-RS implementation such as Jersey, and by programmers (end users) who can use any compatible JAX-RS implementation in the same way.

To use JAX-RS, you need a JAX-RS implementation. Therefore, if one of them is not included in the JDK, you can use an external one. The actual decision about which implementations should be included or not in the JDK is difficult, some interesting criteria can be the maturity and acceptance of the implementation, as well as the frequency of use. (A rarely used function can be downloaded additionally.)

This answer uses the information provided here:

http://www.vogella.com/tutorials/REST/article.html#restjersey

In the second part of your question: servers use related versions. For example, Glassfish uses Metro for JAX-WS, but it depends on the server.

+2
source

Source: https://habr.com/ru/post/1266472/


All Articles