This project provides an example of how a cloud-native Java application can easily call a REST API through generated Java interfaces.
The scenario demonstrates using Amberdata's Web3api to interact with the Ethereum public blockchain to predict gas prices for transactions.
Run the project with the following command. This runs the application in development mode allowing you to access it through the Open Liberty server, while any further changes that you make to the source code will be reflected automatically.
mvn liberty:dev
Open your browser at the following URL to invoke a servlet which accesses Web3api to return predicted gas prices for Ethereum.
- Project layout using MicroProfile Starter
- Java interfaces and models generated using this chain: Web3api REST API for gas predictions -> OpenAPI document -> MicroProfile Rest Client Generator
- Simple servlet making use of the generated REST client through dependency injection, allowing you to simply call it as a Java interface and accessing the Java models directly.