10 RESTful web services

 

This chapter covers

  • Understanding RESTful web services fundamentals
  • Building RESTful web services with JAX-RS and Apache CXF
  • Building RESTful web services with camel-restlet and camel-cxf components
  • Using Camel’s Rest DSL
  • Using Rest DSL with various Camel components
  • Binding between POJOs and XML/JSON
  • Documenting your RESTful services by using Swagger
  • Browsing the Swagger API via the Swagger UI

For over a decade, web services have played an important role in integrating loose and disparate systems together. As a natural evolution of humankind and the IT industry, we learn and get smarter. Recently, RESTful web services (a.k.a. REST services) have taken over as the first choice for integrating services. This chapter covers a lot of ground about developing and using RESTful web services with Camel.

Section 10.1 covers the fundamentals and principles of RESTful services, so you’re ready to tackle the content of this chapter. We provide a lot of examples with source code that focus on a simple use-case that could happen in the real world, if Rider Auto Parts were an actual company. The section continues by explaining how to implement REST services using various REST frameworks and Camel components.

Section 10.2 introduces you to the Rest DSL, which allows you to define REST services the Camel way. You can use the natural verbs from REST together with the existing Camel routing DSL, combining both worlds.

10.1 RESTful services

10.1.1 Understanding the principles of a RESTful API

10.1.2 Using JAX-RS with REST services

10.1.3 Using Camel in an existing JAX-RS application

10.1.4 Using camel-restlet with REST services

10.1.5 Using camel-cxf with REST services

10.2 The Camel Rest DSL

10.2.1 Exploring a quick example of the Rest DSL

10.2.2 Understanding how the Rest DSL works

10.2.3 Using supported components for the Rest DSL

10.2.4 Configuring Rest DSL

10.2.5 Using XML and JSON data formats with Rest DSL

10.2.6 Calling RESTful services using Rest DSL

10.3 API documentation using Swagger

10.3.1 Using Swagger with JAX-RS REST services

10.3.2 Using Swagger with Rest DSL

10.3.3 Documenting Rest DSL services

10.3.4 Documenting input, output, and error codes

10.3.5 Configuring API documentation

10.3.6 Using CORS and the Swagger web console

10.4 Summary and best practices

sitemap