Different types of webservices in Java

The web services world in Java is very complex and vast. As with any technology in Java world, a version of web services starts with JSR (Java Specification Request) which is actual description of proposed and final specification. Based on the specifications, Sun Microsystem provided web services API. Once the web services API is provided by Sun, it is implemented by multiple vendors/companies. This article provides the inforamation of various web services API and their implementation. We also cover the two different architectural styles of web services : SOAP and REST.

Java web services : Different API

Based on different style of communication and web services, Sun has provided below 3 APIs for Java web services:

JAX-RPC : Java API for XML based RPC is based on JSR 101. It is legacy Web Services API and as name suggests uses RPC (Remote Procedure Call) style of communication. JAX-RPC supports SOAP 1.1 and Java SE 1.4 or lower versions. JAX-RPC (JAX-RPC 1.x) is deprecated with Java EE 6.

JAX-WS : Java API for XML-Based Web Services is based on JSR 224. JAX-WS was introduced with Java EE 5. Infact JAX-WS 2.0 was a new name of JAX-RPC 2.0. The name was changed to reflected the move away from RPC style to document style web services. JAX-WS supports SOAP 1.2 and SOAP 1.1 both.

JAX-RS : The Java API for RESTful Web Services (JAX-RS) is based on JSR 311. It supports the implementation of REST based web services.

Java web services : Different Implementations

Various web services framewroks are provided by different companies by implementing the APIs discussed above. The most famous (or commonly used) java web services implementations/frameworks are mentioned below: Apache Axis (Apache eXtensible Interaction System) framework is implementation of SOAP protocol. Axis framework is now obselete and should be avoided in new applications. There are two major versions of Axis: Axis 1.x and Axis 2.x
Axis1 is implementation of JAX-RPC API and support only SOAP based web service.
Axis 2 is based on JAX-WS and has support for RESTful web-services as well. Axis2 can also function as a standalone server application.

Apache CXF originated in 2008 (CXF by merging Celtix and XFire). It provides implementation of both JAX-WS and JAX-RS APIs. CXF is compatible with spring framework.

Jersey is implementation of JAX-RS API. It supports only RESTful web-services and is one of most widely used framework for implementing RESTful web services. Jersey also adds its own functionality over and above JAX-RS making it better and easier. It is reference implementation by Sun itself.

Spring WS Spring web services is a product of the Spring community focused on creating document-driven Web services. Spring WS supports only SOAP based web services (contract first approach only).

Web services : Different Architectural Styles

There are two completely different architectural styles in web-services. SOAP (Simple Object Access Protocol) is a communication protocol (SOAP = XML over HTTP). SOAP based web services are pretty complex as there are so many standards and protocols (WSDL, WS*). But since this is an old style they are more widely used and have more features especially related to things like security etc.

REST stands for REpersentational State Transfer. Its just an architectural style. REST based web services (or RESTful web services) are much simpler to implement and consume. RESTful web services are much ligher also as there is no overhead (SOAP envelop etc). The whole concept of REST is, when we already have HTTP which can do CRUD operations over network why do we need another protocol (SOAP) for doing the same. RESTful web-services are now gaining more and more acceptence in industry. Companies like Google, Yahoo, Amazon, Microsoft, Facebook, twitter are using RESTful web services.

WS Stack.
WS Basic Profile.