Difficulty: Beginner
Estimated Time: 70 Minutes

The definition of each step of this tutorial can be found at https://github.com/devonfw-tutorials/tutorials/tree/main/devon4j-http-rest-client.

Feel free to report any errors to us or fix them yourself. Errors can be reported by creating an issue in the tutorials repository. To fix the error fork the repository and create a pull request. Errors in the wiki can be reported and fixed in the tutorial-compiler repository. You can find a description of what to look for when creating a pull request at the devonfw contribution guide: https://devonfw.com/website/pages/community/community.html#community.asciidoc_contributing-to-devonfw. If you want to create a tutorial you can start with the katacoda tutorial and read the description for creating your own tutorials: https://github.com/devonfw-tutorials/tutorials/wiki/Development.

REST (REpresentational State Transfer) is an inter-operable protocol for services that is more lightweight than SOAP. We give best practices that lead to simple, easy and pragmatic "HTTP APIs".


  • User should have development experience in JAVA.

  • Basic knowledge of REST.

Learning Goal

Here in this tutorial you will learn the following things:

  • JAX-RS standard for REST service implementation proposed by devonfw.

  • How to create REST client with devon4j using Synchronous call.

Let's get started!!

You have successfully created devon4j CXF REST Client. For more details on devon4j follow https://devonfw.com/website/pages/docs/devon4j.asciidoc.html

Develop a devon4j CXF REST Client using Synchronous call

Step 1 of 13


REST (REpresentational State Transfer) is an inter-operable protocol for services that is more lightweight than SOAP.

For implementing REST services we use the JAX-RS standard. As an implementation we recommend CXF. For JSON bindings we use Jackson while XML binding works out-of-the-box with JAXB. To implement a service you write an interface with JAX-RS annotations for the API and a regular implementation class annotated with @Named to make it a spring-bean.

The REST service implementation is a regular CDI bean that can use dependency injection. The separation of the API as a Java interface allows to use it for service client calls.

Why Should you prefer devon4j client over other clients?

devon4j supports flexible configuration, adding headers for authentication, mapping of errors from server, logging success/errors with duration for performance analysis, support for synchronous and asynchronous invocations. Easy invocation of service inside a micro-service. For more details on REST visit https://devonfw.com/website/pages/docs/devon4j.asciidoc_guides.html#guide-rest.asciidoc

For more details on devon4j Service Client https://devonfw.com/website/pages/docs/devon4j.asciidoc_guides.html#guide-service-client.asciidoc

Create the devon4j REST SERVER

As explained in REST document, With JAX-RS it is important to make sure that each service method is annotated with the proper HTTP annotation(@GET, @POST, etc). Let's create devon4j server.

Setting up your Java project

Please change the folder to 'devonfw/workspaces/main'.

cd devonfw/workspaces/main

Now you can use devonfw to setup a Java project for you by executing the following 'devon' command.

devon java create com.example.application.httprestserver

In next step, you will add configuration to allow basic authentication.