You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OCTOPUSCARDS\yanng 5ba204bd59
Update Camel from v4.7.0 to v4.8.2
2 weeks ago
conf Update Camel from v4.7.0 to v4.8.2 2 weeks ago
src/main/java/com/example/camel Update Camel from v4.7.0 to v4.8.2 2 weeks ago
.gitignore V0.0.1 Simple Spring-boot Server Defined by Camel XML Routing 4 months ago
pom.xml Update Camel from v4.7.0 to v4.8.2 2 weeks ago
readme.adoc Update Camel from v4.7.0 to v4.8.2 2 weeks ago

readme.adoc

== Spring Boot Example with Camel exposing REST services using Apache CXF


=== Introduction

This example illustrates how to use https://projects.spring.io/spring-boot/[Spring Boot] with http://camel.apache.org[Camel]. It provides a simple REST service that is created using https://cxf.apache.org/[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
[source,text]
----
$ curl http://localhost:8080/services/api/user -s | jq .
----

The command will produce the following output:

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

Retrieve a specific user
[source,text]
----
$ curl http://localhost:8080/services/api/user/1 -s | jq .
----

The command will produce the following output:

[source,json]
----
{
"id": 1,
"name": "John Coltrane"
}
----

Insert/update user

[source,text]
----
$ 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 https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml#http-status-codes-1[201]

Moreover, the input user is validated according to the annotations on the link:src/main/java/org/apache/camel/example/springboot/cxf/User.java[User bean]

[source,text]
----
$ 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
https://camel.apache.org/community/support/[let us know].

We also love contributors, so
https://camel.apache.org/community/contributing/[get involved] :-)

The Camel riders!