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”
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.
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”
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.
It is advisable to structure the code in such a way so that the code could be easily tested on several distinct areas:
- the code that launches the thread and wait for result.
- the worker code that runs in the thread.
- the concurrency issue may occur when multiple threads are active.
Continue reading “Writing Junit Test on Java Thread”
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 https://www.roytuts.com/calculate-future-or-past-date-in-php/ Continue reading “Future or Past Date in Java”
This examples shows how to move all non-zero elements(if any) in an array to the left and all zero elements to the right in the array using Java.
Continue reading “Move Non-Zero Array Elements to Left 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 https://en.wikipedia.org/wiki/Josephus_problem
Continue reading “Solving Josephus problem using Java”
Tic-tac-toe (also known as noughts and crosses or Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game.
For more information on tic-tac-toe please read https://en.wikipedia.org/wiki/Tic-tac-toe
Continue reading “Tic-tac-toe game using Java”
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”
Test-driven development is related to the test-first programming concepts of extreme programming(https://en.wikipedia.org/wiki/Extreme_programming).
Life cycle of test-driven development
1. Write a test
2. Run the written test
3. Write code that corrects the failing test
4. Clean up your code
5. Go to step 1. Continue reading “TDD – Test Driven Development”
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”