JAX-WS Hello World Example


JAX-WS (Java API for XML Web Services) is a Java API for developing web services and clients.

In this example, we will use JAX-WS to create : a web service to expose a simple method, and a client to consume this method.

The service provider (web service) and the client will communicate using the XML-based protocol : SOAP


1. Technologies used

  • Eclipse 4.4
  • JDK 1.7


2. Server project structure

Start Eclipse and Select File >  New  > Java Project : JAX-WS-Hello-World-Server



3. JAX-WS Web Service Endpoint

An endpoint is a connection point for configuring JAX-WS service providers.

So, we first create the service to expose by creating a web service endpoint.

3.1. Create Web Service Endpoint Interface : Welcome


3.2. Create Web Service Endpoint Implementation : WelcomeImpl


3.3. Create Endpoint PublisherWelcomePublisher

It is used to publish the Web Service to the clients.


We run the WelcomePublisher to deploy our web service. We can then check the service :




4. JAX-WS Web Service Client

Now, we will create a client program to consume the Welcome service.

In Eclipse, Select File >  New  > Java Project : JAX-WS-Hello-World-Client

4.1. wsimport utility

We will use wsimport utility to parse the wsdl file and automatically generate the necessary java classes needed to create our client program.

In a command line, tape :

All the Java classes will be generated in %JAX-WS-Hello-World-Client_PATH%/src



4.2 Create the Client class : WelcomeClient

We have remotely called the sayHello(..) method of the  Welcome service.

Output :

Hello Walid


Download source code