JAX-WS is a high-level API that simplifies the development of SOAP-based web services. JAX-WS stands for Java API for XML Web Services. Developing a web service via JAX-WS consists of writing a class with public methods to be exposed as web services. The class needs to be decorated with the @WebService annotation. All public methods in the class are automatically exposed as web services. They can optionally be decorated with the @WebService annotation. The following example illustrates this process:
package net.ensode.glassfishbook;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class Calculator {
@WebMethod
public int add(int first, int second) {
return first + second;
}
@WebMethod
public int subtract(int first, int second) {
return first - second;
}
...