Kesha Williams explains the RESTful architecture, JAX-RS, and JSON.
- [Narrator] REST stands for Representational State Transfer, and is an architectural style of services that utilizes web standards. It is designed to use a stateless communication protocol, typically http or https. In the REST architectural style, clients and servers exchange representations of resources by using a standardized interface and protocol. There are several principles that encourage RESTful applications to be simple, lightweight and fast.
First is the resource identification, through a uniform resource identifier, or a URI. Data and functionality are considered resources, and are typically accessed via links on the web. The second is the uniform interface. Resources are manipulated using a fixed set of operations: GET to retrieve a resource, POST to create a resource, PUT to update a resource, and DELETE to remove a resource.
Thirdly, self-descriptive messages: A resource can be represented in multiple formats, such as HTML, XML, plain text, pdf, jpeg, JSON, and other document formats defined by a media type. And lastly, stateful interactions through links: Communication between the client and the endpoint should be stateless. The necessary state can be passed by the client in each invocation.
JAX-RS makes it easy for developers to build RESTful web services using the Java programming language and the REST architecture. JAX-RS is a specification, or a set of interfaces and annotations offered by Java EE. Since it's just a specification, there are implementations. Some of the more well-known are RESTEasy and Jersey. Since we are using the WildFly, i.e., JBoss, server, it comes with RestEasy so that's what we'll be using in this course.
Here's a tip. It is important to know which implementation your server supports so that you can take full advantage of what the platform offers. This is very important at the beginning of the project or when migrating the project to another server. The JAX-RS API uses Java programming language annotations to simplify the development of RESTful web services. Developers simply add the necessary annotations to plain old Java objects to turn them into resources.
The resource methods can generate an XML or JSON representation. During this course the chosen format is JSON because it is lightweight and easy to parse.
- Comparing when to use JAX-WS vs. JAX-RS
- Using JAX-RS annotations
- Accessing REST resources with JAX-RS
- Creating JAX-WS endpoints
- Writing RESTful services using JAX-RS
- Reading, writing, updating, and deleting data via endpoints
- Mapping to entities
- Error handling
- Testing web services
- Securing Java EE web services