The Java community at Xperti has been following what’s new in Java web services, and has much to add to the same.
A web service creates communication between server applications and the client. It can be in the form of messages, documents, objects, and/or programs. What makes it unique is its ability to communicate ‘between’ different programming languages.
For instance, PHP and .NET can contact Java and vice-versa. Being a very robust, popular language, it was no surprise when Java offered web services too.
In the past five years, several new cloud-based services have come up. New frameworks, new versions, minor updates etc are coming up to match this evolution. There are already many different types of web services available. These include SOAP, UDDI, REST, and XML-RPC.
SOAP and REST are the most prominent names in the industry. This is why we focus on the latest developments in these two web services here.
RESTEasy is an implementation of the Jakarta RESTful Web Services. This is an Eclipse Foundation specification that provides a Java API for RESTful Web Services over the previously used HTTP protocol. The final release (3.12.0) was made available in May 2020.
What’s great about RESTEasy is that it:
- Is portable to Tomcat and many other app-servers
- Provides embedded-able server implementation for JUnit testing
- Offers an enhanced client framework
- Offers JAXB marshalling into XML, JSON, Jackson, Fastinfoset, and Atom. Together with wrappers for maps, arrays, lists, and sets of JAXB Objects.
- Has a rich interceptor model
- Offers enhanced security, by providing digital signature and encryption support with S/MIME and DOSETA
EJB, Seam, Guice, spring, Spring MVC and Spring Boot integration is also available.
Spring Web Services
Spring Web Services or Spring-WS focuses on creating document-driven web services. Spring Web Services facilitate contract-first SOAP service development. This allows Java developers to create flexible web services. This, in turn, gives them the liberty to manipulate XML payloads as per their requirements. The great thing about this product, (especially for other Spring product users)! is that it’s been made by the top developers behind Spring itself!
So Spring users can apply Spring concepts like dependency injection as an integral part of their web service. Developers have started using Spring-WS for many reasons. The primary reason, though, is that alternative SOAP stacks lag behind in web service best practices’ compliance.
Its latest version (3.0.9) was released in April 2020.
Some key features of Spring Web Services include:
Making it easy to enforce best practices. E.g. the WS-I basic profile, contract-first development, and loose coupling between contract and implementation.
With Spring Web Services, Java developers can distribute incoming XML request to any object. (Depending on message payload, SOAP Action Header, or an XPath expression).
It provides support for WS-Security, which allows developers to:
- Sign SOAP messages
- Encrypt/decrypt them
- Or conduct authentication against them
The best thing? Java coders can reuse their Spring expertise. Spring-WS uses Spring application contexts for all configuration, which should help Spring developers. The architecture of Spring-WS also resembles that of Spring-MVC.
The Jersey Framework is a web services framework designed for creating RESTful services. But it also supports JAX-RS APIs. The development of RESTful services has been simplified a great deal. Mainly by providing useful features and utility functions. Thanks to top tech talent, Jersey provides a kind of “abstraction layer.” As a result, developers do not have to worry about low-level implementation of client-server communication. They can concentrate on the main web service functionalities.
A unique feature of Jersey is that it allows for chunked output which is not offered by other RESTful frameworks. This comes in handy when sending large datasets.
PostInvocationInterceptor, and InvocationBuilderListener interfaces were introduced with the Jersey 2.30.1 release earlier this year.
The brains behind this breakthrough also made the Apache HttpClient Connector working with the new Apache Http Client “as fine as the old days”. It now also allows the MP REST Client to work with any Jersey Connector.
It is also the first release that is fully-buildable and works on JDK 13.
Jersey 2.30.1 fixed the bug for the core-common multi-release jar, which works with JDK11. In future releases, developers have plans to support JDK 14. Jersey 3.x will be compatible with Jakarta RESTful WebServices 3.x.y API. At the moment, they do not use the javax.ws.rs java package.
Do we expect web services to gather an even bigger audience? Yes. Even within the Java ecosystem, developers have many choices at their disposal. The development and integration front looks more exciting than ever!