Often times, JAX-WS always be part of your Java web application. Here we show you how to integrate JAX-WS into Java web application easily.

1. Project Folder

First, review this project folder structure.
jax-ws-web-application-example

2. Web Service

A super simple web service. Code is self-explanatory.
File : HelloWorld.java
package com.mkyong.ws;
 
import javax.jws.WebMethod;
import javax.jws.WebService;
 
@WebService
public class HelloWorld{
 
 @WebMethod(operationName="getHelloWorld")
 public String getHelloWorld(String name) {
  return "Hello World JAX-WS " + name;
 }
 
}

3. Web Service Deployment Descriptor (sun-jaxws.xml)

Create a web service deployment descriptor, named sun-jaxws.xml.
File : sun-jaxws.xml
 version="1.0" encoding="UTF-8"?>

  xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
  version="2.0">
  
      name="HelloWorldWs"
      implementation="com.mkyong.ws.HelloWorld"
      url-pattern="/hello"/>