Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Definition of JAX-WS and JAX-RS [closed]

I read somewhere in the internet that JAX-WS is a SOAP implementation and JAX-RS a Rest implementation. Is this true? Are JAX-WS and JAX-RS implementations or specifications?

Thanks in advance.

like image 920
Carlos Avatar asked Oct 16 '25 04:10

Carlos


2 Answers

They are specifications that define APIs.

  • JSR 224: Java API for XML-Based Web Services (JAX-WS) 2.0 http://jcp.org/en/jsr/detail?id=224
  • JSR 311: JAX-RS: The JavaTM API for RESTful Web Services http://jcp.org/en/jsr/detail?id=311

The APIs (interfaces, classes, and exceptions) they define require implementations.

The reference implementation (RI) for JAX-WS is included in Java SE. The JAX-WS RI is created as part of the Metro project (http://metro.java.net/). Metro includes enhancements and features beyond what the JAX-WS RI supports. In the SOAP world there are optional features like WS-Security that a web service stack can support. Metro supports those while the JAX-WS RI does not.

Since the JAX-WS is included in Java SE, yes you can make JAX-WS (SOAP) web services without a server. This is because there is a very basic HTTP server included in Java SE. You use the Endpont class to publish a service. This is really meant more for testing than anything else. The real reason JAX-WS is included in Java SE is to make it easier to be a SOAP service client. To truly run a JAX-WS web service you need a server such as GlassFish, JBoss, or WebLogic. There is some ability to add a JAX-WS implementation to Tomcat but only a true Java EE Application Server includes a complete implementation out of the box.

The reference implementation (RI) for JAX-RS is named Jersey (http://jersey.java.net/). JAX-RS is not included in Java SE. You must download an implementation. Once you download it you could use it without a server but again, it is really meant more for use in a server. One reason you download Jersey is to get the Jersey Client API to write clients (which is not a part of the current JAX-RS specification). Like with a JAX-WS implementation, you can add Jersey to Tomcat or a full Java EE Application Server will include a JAX-RS implementation.

like image 52
Chase Avatar answered Oct 17 '25 16:10

Chase


JAX-WS and JAX-RS are both libraries (APIs) for doing communication in various ways in Java.

As you mentioned, JAX-WS is a library that can be used to do SOAP communication in Java, and JAX-RS lets you do REST communication in Java.

like image 23
Oleksi Avatar answered Oct 17 '25 18:10

Oleksi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!