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.

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.

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.

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

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

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.wsdlThis will generate Java files in a 'axis2/services' folder. Move these files to the 'src/main/java' folder of your project.

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.




















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
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!