In the modern era, security is an essential feature in any application, your REST services are no exception to it. In this short tutorial, we’ll discuss how to secure your REST APIs with BASIC authentication. We’ll use Spring Security to implement the security of the API
We’ll use a fictitious application that lets us manage our favorite web URLs. Let us call this application Pocket. It has the following endpoints:
GET /pockets: Returns all available pockets
GET /pockets/{id}: Returns the available pocket for the supplied id. Return an error for invalid ids
POST /pockets: Create a new pocket
PUT /pockets…
Spring Web services is an alternative way to develop document-driven, contract-first SOAP web services. One of the main reasons to use Spring-WS is that it has built-in Spring integration and features such as dependency injection.
In this article, we will demonstrate how to consume a soap web service with Spring boot.
We are consuming a SOAP web service that provides Medium article details. This web service has only one operation named getArticle. The SOAP request message accepts an article ID of the article and returns the article details in the response. Following is the WSDL definition file:
By default, Spring Boot applications are shipped with an embedded tomcat container and packaged as an executable UBER jar. This fat jar can be executed in console without the need for an application server. However, at times we need to package the application as a WAR file and deploy it into a web/application server. In this article, we will discuss how to package a Spring Boot application as a WAR file and deploy it into the WildFly application server.
Let us first set up the WildFly application server. This server can be freely downloaded from the WildFly website. Based on…
SOAP Web Services (Spring-WS) is an offering from Spring Framework that facilitates creating document-driven, contract-first SOAP web services. One of the main reasons to use Spring-WS is that it has built-in integration with Spring Framework and the ability to leverage major Spring features such as dependency injection. Also, the architecture of Spring-WS resembles that of Spring-MVC and this makes the learning of Spring-WS much easier.
In this article, we will develop a contract-first soap web service with Spring boot. In the development process, we will highlight the core Spring-WS features.
We are developing a SOAP web service that let users…
The popularity of REST Web service is ever-increasing and REST API based application design is the standard in the enterprise space. An API defines a contract between the API publisher and its consumers. This contract includes several aspects of the API; including the endpoints, request-response model, domain objects and so on. Over the last couple of years, Swagger has emerged as the standard to document the REST APIs. Swagger captures the API definitions in JSON or YAML format adhering to the OpenAPI specification. A Swagger document can be shared with API consumers for quick prototyping and mocking.
Swagger also provides…
Java has introduced functional programming support in Java release version 8. This specific release has also introduced several new concepts notably lambda expressions, method reference and a plethora of functional interfaces. While discussing functional interfaces, there are few functional interfaces namely Consumer, Supplier, Predicate and Functions are most crucial. In this article, we will talk about these interfaces.
A Consumer is a functional interface that accepts a single input and returns no output. In layman’s language, as the name suggests the implementation of this interface consumes the input supplied to it. Consumer interface has two methods:
void accept(T t); default…
Introduction of annotation in Java programming language has changed the way Java developers used to configure their applications. Its introduction in Java 1.5 has empowered application developers to maintain configurations in the source code itself instead of relying on external configuration files. It is a form of syntactic metadata that can be added to Java Source code classes, methods, variables, parameters and packages.
Spring framework let application developer configure applications with a plethora of in-build annotations. In this article, we will focus on a few most frequently used annotations in Spring Core framework.
This annotation is used to declare a…
Security is an important aspect of any application and nearly all production-grade applications employ a certain level of security mechanism for application security. Transport Layer Security allows applications to develop a secure communication channel with its clients. In this article, we will create a Spring boot application and secure it with a self-signed certificate.
In this section, we will create a Spring boot application and expose the following endpoints:
GET v1/books/ : List all books
POST v1/books/: Create a new book
GET v1/books/{book_id}: Get a book resource
DELETE v1/books/{book_id}: Remove a book
Browse to your favorite IDE and create a…
Dropwizard is a Java framework to develop RESTful web services. It pulls together mature and stable libraries from the Java ecosystem into a lightweight, simple package that let's build production-grade applications. It also provides out-of-box support for configuration, application metrics, logging, and other operational tools.
The most interesting part of Dropwizard is its selection of libraries in order to perform the job. It pulls together best-of-the-class libraries from each domain and let the application developer focus on their task.
Dropwizard uses a plethora of libraries to provide various services in a traditional Dropwizard application. Following are a few critical selections:
…
Node JS is a JavaScript runtime built on top of Chrome’s V8 JavaScript engine and allows the use of JavaScript on the server-side. Express JS a minimal and flexible web framework build on top of Node JS with a plethora of features to develop web and mobile applications. MongoDB is one of the most popular document-based, NoSQL database. Together these three technologies facilitate building a highly flexible, scalable and robust application.
In this article, we will talk about how to design an application leveraging these technologies.
In this article, we will develop a RESTful API with the aforementioned technologies. We…
Full Stack Developer ★ Technical Writer