Home

 

Annotations

JAX-WS introduces support for annotating Java classes with metadata to indicate that the Java class is a Web service. JAX-WS supports the use of annotations based on the Metadata Facility for the Java Programming Language (JSR 175) specification, the Web Services Metadata for the Java Platform
(JSR 181) specification and annotations that are defined by the JAX-WS 2.0/2.1 specification. Using annotations in the Java source and in the Java class simplifies development of Web services by defining some of the additional information that is typically obtained from deployment descriptor files, WSDL files, or mapping metadata from XML and WSDL files into the source artifacts.

For example, you can embed a simple @WebService annotation in the Java source to expose the bean as a Web service (Example | 8-1).

Example 18-1 JAX-WS annotation

@WebService 
public class BankBean {
	public String getCustomerFullName(String ssn) { ... }
}

The @WebService annotation tells the server runtime environment to expose all public methods on that bean as a Web service. Additional levels of granularity can be controlled by adding additional annotations on individual methods or parameters. Using annotations makes it much easier to expose Java artifacts as Web services. In addition, as artifacts are created from using some of the top-down mapping tools starting from a WSDL file, annotations are included within the source and Java classes as a way of capturing the metadata along with the source files.

ibm.com/redbooks