How to do a SOAP Web Service call from Java class

This example will show you how to do a SOAP web service call from Java class. Normally you would use the web service library for invoking the SOAP service but in some cases this could be useful and quick. For example, you may have problems generating a client proxy with a web service library or if you only need some small specific parts of the response. It is just a SOAP call over HTTP, from a plain piece of Java code without using any Java library. In fact you can invoke SOAP service from any language being web service platform independent.

Now in order to consume the service or SOAP web service call from Java class, we must have the service deployed somewhere. So please read Spring SOAP WebService Producers using Gradle before consuming this SOAP service. We will create here client which will consume the service in the given link. If you want to use library to consume the service then you can read Spring SOAP WebService Consumers using Gradle

Continue reading “How to do a SOAP Web Service call from Java class”

Server Sent Events with Spring – Push Notifications


We have seen a popular choice for sending real time data from server to client in web application is using WebSocket in our previous tutorials Messaging with STOMP over WebSockets using Spring and ActiveMQ and Spring Boot WebSocket AngularJS Gradle Example. WebSocket opens bidirectional connections between server and client. So both server and client can send messages. But sometimes we face situations, where the application needs only one way communication, i.e., sending data from server to the client and for this Spring provides a simpler solution using Server Sent Events (SSE). SSE is a technology that allows you to stream data from server to the browser  (Push Notifications) within one HTTP connection in one direction. For example, pushing stock price changes in real-time or showing progress of long-running process or real time showing of cricket or football scores on display board etc.

Browser Support

SSE are supported in most modern browsers. Only Microsoft’s IE and Edge browsers do not have a built in implementation. But there is a way out because Server-Sent Events uses common HTTP connections and can therefore be implemented with the following libraries to support IE and Edge browsers.

Continue reading “Server Sent Events with Spring – Push Notifications”

Writing Junit Test on Java Thread

In this tutorial you will see how to write test case on Java thread using junit. Writing junit to test thread in Java will show an example on single threaded environment.


Java 8



It is advisable to structure the code in such a way so that the code could be easily tested on several distinct areas:

  1. the code that launches the thread and wait for result.
  2. the worker code that runs in the thread.
  3. the concurrency issue may occur when multiple threads are active.

Continue reading “Writing Junit Test on Java Thread”

Future or Past Date in Java

This tutorial will show you how can you calculate either future date from a particular date to “plus a number of given days” or past date from a particular date to “minus a number of given days”.

Future or past date calculation may be required for various purposes such as to calculate the age of a person on future date or on past date.

I will show you this calculation in Java language. If you need to calculate in PHP please read here Continue reading “Future or Past Date in Java”

Solving Josephus problem using Java

The Josephus problem (or Josephus permutation) is a theoretical problem related to a certain counting-out game.

You may also like to read Solving Josephus problem using PHP

People are standing in a circle waiting to be executed. Counting begins at a specified point in the circle and proceeds around the circle in a specified direction. After a specified number of people are skipped, the next person is executed. The procedure is repeated with the remaining people, starting with the next person, going in the same direction and skipping the same number of people, until only one person remains, and is freed.

For more information you can read

Continue reading “Solving Josephus problem using Java”

Manage Jenkins – Configuring JDK, GIT and Maven

Here I will show you how to manage Jenkins – configuring JDK, GIT and Maven installations. We build mainly Java applications (also .NET applications) using Jenkins. Therefore we need to have everything which are required to perform build operation of Java applications, i.e., we need to have JDK, GIT or SVN or any other source repository and Maven or Gradle in order to build the applications.

You may also like to read:

Jenkins setup in Windows

Creating and building jobs in Jenkins

Jenkins: Detecting the current branch failed: ref HEAD is not a symbolic ref

Deploy both war and jar files into Nexus using maven in Jenkins

Continue reading “Manage Jenkins – Configuring JDK, GIT and Maven”

Creating Custom HashMap in Java

Here we will see how to create a custom HashMap uaing Java language. We have seen the built-in implementation of HashMap in Java API and we know how HashMap works and its usages.

The intention of this example is not to create a rigid HashMap that provides the same functionalities as Java API provides but to give an idea how you can create your own HashMap.

We know also how HashMap works internally and here also we will look into the internal works of HashMap with same basic functionalities.

Continue reading “Creating Custom HashMap in Java”