Skip to content

Latest commit

 

History

History
91 lines (62 loc) · 2.19 KB

README.adoc

File metadata and controls

91 lines (62 loc) · 2.19 KB

Spring Boot Example with Camel exposing REST services using Apache CXF

Introduction

This example illustrates how to use Spring Boot with Camel. It provides a simple REST service that is created using Apache CXF.

Build

You can build this example using:

$ mvn package

Run

You can run this example using:

$ mvn spring-boot:run

After the Spring Boot application is started, you can open the following URL in your web browser to access the list of services: http://localhost:8080/services/ including WADL definition

You can also access the REST endpoint from the command line:

List all the users

$ curl http://localhost:8080/services/api/user -s | jq .

The command will produce the following output:

[ {
  "id" : 1,
  "name" : "John Coltrane"
}, {
  "id" : 2,
  "name" : "Miles Davis"
}, {
  "id" : 3,
  "name" : "Sonny Rollins"
} ]

Retrieve a specific user

$ curl http://localhost:8080/services/api/user/1 -s | jq .

The command will produce the following output:

{
  "id": 1,
  "name": "John Coltrane"
}

Insert/update user

$ curl -X PUT http://localhost:8080/services/api/user --data '{"id":4,"name":"Charlie Parker"}' -H 'Content-Type: application/json' -v

The http status code of the response will be 201

Moreover, the input user is validated according to the annotations on the User bean

$ curl -X PUT http://localhost:8080/services/api/user --data '{"id":4,"name":"C"}' -H 'Content-Type: application/json'

will produce a validation error

The Spring Boot application can be stopped pressing [CTRL] + [C] in the shell.

Help and contributions

If you hit any problem using Camel or have some feedback, then please let us know.

We also love contributors, so get involved :-)

The Camel riders!