Consume web services with Spring Boot and Spring Web Services.

Image for post
Image for post
Image Courtesy: Unsplash by Casey Horner

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.

What are we Building?

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:

article.wsdl

Complete source code of the SOAP project can be found here. …


Build and Deploy a Spring Boot application in Wildfly Server through Maven

Image for post
Image for post
Image Courtesy: Unsplash by JOHN TOWNER

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.

Setting up WildFly Server

Let us first set up the WildFly application server. This server can be freely downloaded from the WildFly website. Based on the operating system type, download the ZIP or the TGZ version. In this demonstration, we will use the ZIP version. Once downloaded, unzip and browse to WILDFLY_HOME/bin and run the add-user (.sh/.bat)


Design document-driven, contract-first SOAP web services with Spring Boot and Spring Web Services.

Image for post
Image for post
Image Courtesy: Unsplash by ᴠɪᴋᴛᴏʀ ꜰᴏʀɢᴀcs

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.

What are we Building?

We are developing a SOAP web service that let users perform basic arithmetic calculation such as addition, subtraction, multiplication, and division. Note that Spring supports contract-first web service development. In the contract-first design approach, the service definitions are designed before the actual coding is done. In the next section, let us define the WSDL of our service. …


Swagger let us document REST APIs and shares with API Users. It also allows us to generate REST stubs for quick prototyping and mocking

Image for post
Image for post
Image Courtesy: Unsplash by Andy Art

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 an excellent code generation tool to parse and mock the endpoints defined in a Swagger API specification document. This utility let API consumers generate REST client in several languages. In this article, we will talk about how to generate a Node JS REST client from a given Swagger API specification document. …


Functional programming in Java in a better way.

Image for post
Image for post
Image Courtesy: Unsplash by Daryan Shamkhali

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.

Consumer

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 Consumer<T> andThen(Consumer<?

Most frequently used core annotations in Spring application development

Image for post
Image for post
Image Courtesy: Unsplash by the_roaming_platypus

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.

#1. @Autowired Annotation

This annotation is used to declare a dependency in a class. Based on the presence of this annotation, Spring DI framework injects this dependency. This can be used with constructor, fields and setter methods. This is an alternative to the JSR-330 (Dependency Injection for Java) @Inject annotation. …


Securing an application with Transport Layer Security and a Self-Signed Certificate

Image for post
Image for post
Image Courtesy: PixaBay

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.

Creating a Spring Boot Application

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

Step 1: Creating a Spring Boot Project

Browse to your favorite IDE and create a Spring boot project with web, h2, data-jpa and Lombok dependencies. Following is the pom.xml …


Dropwizard is a Java framework for developing operations-friendly, high-performance, RESTful web services

Image for post
Image for post

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.

Notable Libraries

Dropwizard uses a plethora of libraries to provide various services in a traditional Dropwizard application. Following are a few critical selections:

Jetty for HTTP

Any web application must have an HTTP server to function as a web application. Dropwizard uses an embedded Jetty container to run the application. Thus, it takes away the complexities of packing the application as an archive and deploy into an application server. This also eliminates a plethora of production issues such as app server configuration, class loader troubles, application logs, memory, and myriad other things. A Dropwizard application has a simple main method that bootstrap the jetty container at application startup and the Dropwizard application is ready to serve. …


Creating scalable, flexible and robust APIs with MERN stack

Image for post
Image for post
Image Courtesy: Unsplash by Nghia Le

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.

Our Application

In this article, we will develop a RESTful API with the aforementioned technologies. We will develop an application from scratch and as we proceed with the application, we will add the various layers in our demo application. As part of this demonstration, we will design a book management solution that will let API clients manage books. …


JShell provides the REPL feature in Java and makes it less verbose

Image for post
Image for post
Image Courtesy: Unsplash by Marc Rentschler

The Java Shell Tool or in short JShell is a major addition in Java 9. Before the introduction of JShell, there was no way one could do REPL (Read-Evaluate-Print-Loop) in Java. A REPL is a simple, interactive programming environment that takes user input (Read), executes the user command (Evaluate), returns the result to the user (Print) and waits for the next user input (Loop).

In fact, to even print a single statement in the console it was absolutely necessary to at least have a class and the main method in it. JShell attempts to take away that pain to a certain extent and adds a full-fledged REPL feature in the Java programming language. JShell is an interactive tool that is useful to learn Java language features, APIs and allows quick prototyping, debugging without the need for full-fledged classes. …

About

Somnath Musib

Full Stack Developer ★ Technical Writer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store