Java SOAP Web Service Server Example

Joyce Jul 13, 2026

Java SOAP web services are a robust and widely-used method for enabling communication between different applications over the internet. They are based on the Simple Object Access Protocol (SOAP) standard, which uses XML to format its messages and HTTP or SMTP to transmit them. This article will guide you through creating a simple Java SOAP web service server using Axis2, a popular open-source SOAP server.

How to send SOAP Requests using the Postman Client? | SOAP Web Services | Web Services Tutorial
How to send SOAP Requests using the Postman Client? | SOAP Web Services | Web Services Tutorial

Before we dive into creating the server, make sure you have Java Development Kit (JDK) 1.8 or above installed, along with Apache Axis2 version 1.7.x or later. You'll also need an IDE like Eclipse for coding and testing.

a diagram showing the different types of servers and their respective services, including servers
a diagram showing the different types of servers and their respective services, including servers

Setting Up the Java SOAP Web Service Server

To set up the server, we'll create a new project in Eclipse, add the necessary Axis2 libraries, and configure the servlet container.

Report Server Web Service - SQL Server Reporting Services (SSRS)
Report Server Web Service - SQL Server Reporting Services (SSRS)

After creating the project, add the following Axis2 JAR files to your Build Path: axis2-transport-http.jar, axis2-transport-local.jar, axis2-wsdl2codeгенген.jar, and axis2-kernel.jar. You can find these in the 'lib' folder of your Axis2 installation.

Creating the WSDL

Client Challenge
Client Challenge

A Web Services Description Language (WSDL) file is like a blueprint for your web service. It describes whatoperations (methods) the service exposes, their input and output parameters, and how to call them.

Let's create a simple WSDL file named 'calculator.wsdl' with a single operation 'add' that takes two integers and returns their sum.

Generating the Service Skeleton

ColdFusion SOAP Web Service Not Responding
ColdFusion SOAP Web Service Not Responding

Using the wsdl2code tool, we can generate Java code from our WSDL file. This will create a service skeleton with the methods described in the WSDL. In your project's root folder, run the following command:

wsdl2code -cp axis2-wsdl2codegen.jar -d . calculator.wsdl

This will generate Java files in a 'axis2/services' folder. Move these files to the 'src/main/java' folder of your project.

java basics
java basics

Testing the Java SOAP Web Service Server

Now that we have our server set up and the service skeleton generated, let's test our web service using the Axis2management console.

How to design a simple dashboard UI using Swing and Java -Netbeans
How to design a simple dashboard UI using Swing and Java -Netbeans
Top 10 Servlet Interview Question Answers for Java JEE Developers
Top 10 Servlet Interview Question Answers for Java JEE Developers
#2 JavaFX UI Design Dashboard Utility
#2 JavaFX UI Design Dashboard Utility
Java Swing : School Management System Inspiration
Java Swing : School Management System Inspiration
Java Swing UI Redone
Java Swing UI Redone
an image of a computer screen with some text on it
an image of a computer screen with some text on it
the account settings page on an orange and white website
the account settings page on an orange and white website
Java EE Web Profile vs Java EE Full Platform
Java EE Web Profile vs Java EE Full Platform
JAVA - Student Information System Project In Java Using NetBeans With Source Code | Part 0 - ...
JAVA - Student Information System Project In Java Using NetBeans With Source Code | Part 0 - ...
How to Develop a Role-based Login Application in Java?-Krazytech
How to Develop a Role-based Login Application in Java?-Krazytech
☕ Java Basics Cheat Sheet for Beginners | Learn Java in One Page 🚀
☕ Java Basics Cheat Sheet for Beginners | Learn Java in One Page 🚀
Java Survival Minecraft Server Invite
Java Survival Minecraft Server Invite
Java Swing UI - SignUp Example KControls
Java Swing UI - SignUp Example KControls
Soap Making Software for Soapmakers
Soap Making Software for Soapmakers
Interface in Java
Interface in Java
📦 Java Packages Explained in 60 Seconds! ⏱️
📦 Java Packages Explained in 60 Seconds! ⏱️
Free Editable Java Servlet UML Package Diagram|EdrawMax
Free Editable Java Servlet UML Package Diagram|EdrawMax
Java-Java Server Pages
Java-Java Server Pages
a laptop computer sitting on top of a desk next to a white toilet and sink
a laptop computer sitting on top of a desk next to a white toilet and sink
Java Server pages- Know the complete lifecycle.
Java Server pages- Know the complete lifecycle.

To start the management console, run the 'axis2server.bat' file (on Windows) or 'axis2server.sh' (on Unix/Linux/macOS) from the root folder of your project. Open your browser and navigate to to access the management console.

Deploying the Service

From the management console, navigate to the 'Deploy' page. You'll see your new service listed. Click 'Deploy' to deploy it. The status should change to 'started'.

Now, you can test your service using the 'Test' button. Enter two integers and click 'Invoke'. The server should respond with the sum of those integers.

Consuming the Web Service

To consume this web service, you can use a SOAP client like Apache CFX or SoapUI, or create a Java client using the generated service skeleton. You can find more information about consuming web services with Java in our upcoming guide.

With practice, you'll become comfortable creating and using Java SOAP web services. This simple calculator example is just the starting point. Next, you can create more complex services with different data types, SOAP headers, and cardinalities. Happy coding!