Spring Web Services
Exercise: Todo REST Client
The objective of this exercise is to implement a RESTful client of the todo web service using the Spring Rest template.
Assignment
- Preparation
- Remove the service artifacts from the todo application
- Remove the JPA annotations from the
Todo
class
- Add the
org.springframework:spring-web
and com.fasterxml.jackson.core:jackson-databind
dependencies to the Maven project
- Client implementation
- Create a
TodoProxy
component that implements the TodoList
interface
- Use the Spring
RestClient
to send REST requests to the web service (see API Documentation)
- In the
findTodo
and updateTodo
methods catch the HttpClientErrorException.NotFound
exception, get the problem detail from the response body and rethrow a TodoNotFoundException
Solution