Java API for XML-Based Web Services (JAX-WS) relies on the use of annotations to specify metadata associated with Web service implementations and to simplify the development of Web services. Annotations describe how a server-side service implementation is accessed as a Web service or how a client-side Java class accesses Web services.
The JAX-WS programming standard introduces support for annotating Java classes with metadata that is used to define a service endpoint application as a Web service and how a client can access the Web service. JAX-WS supports the use of annotations based on the Metadata Facility for the Java Programming Language (Java Specification Request (JSR) 175) specification, the Web Services Metadata for the Java Platform (JSR 181) specification and annotations defined by the JAX-WS 2.0 (JSR 224) specification which includes JAXB annotations. Using annotations from the JSR 181 standard, you can simply annotate the service implementation class or the service interface and now the application is enabled as a Web service. Using annotations within the Java source simplifies development and deployment 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 into the source artifacts.
Use annotations to configure bindings, handler chains, set names of portType, service and other WSDL parameters. Annotations are used in mapping Java to WSDL and schema, and at runtime to control how the JAX-WS runtime processes and responds to Web service invocations.
Annotation class: | Annotation: | Properties: |
---|---|---|
javax.jws.WebService | The @WebService annotation marks a Java class
as implementing a Web service or marks a service endpoint interface (SEI)
as implementing a Web service interface. Important: • A Java class that implements a Web service must specify either the @WebService or @WebServiceProvider annotation. Both annotations cannot be present. This annotation is applicablek on a client or server SEI or a server endpoint implementation class for a JavaBeans endpoint. • If the annotation references an SEI through the endpointInterface attribute, the SEI must also be annotated with the @WebService annotation. • See Rules for methods on classes annotated with @WebService for additional information. |
|
javax.jws.WebMethod | The @WebMethod annotation denotes a method that
is a Web service operation. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint. Important: • The @WebMethod annotation is only supported on classes that are annotated with the @WebService annotation. |
|
javax.jws.Oneway | The @Oneway annotation denotes a method as a
Web service one-way operation that only has an input message and no output
message. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint. |
|
javax.jws.WebParam | The @WebParam annotation customizes the mapping
of an individual parameter to a Web service message part and XML element. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint. |
|
javax.jws.WebResult | The @WebResult annotation customizes the mapping
of a return value to a WSDL part or XML element. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint. |
|
javax.jws.HandlerChain | The @HandlerChain annotation associates the Web
service with an externally defined handler chain. You can only configure the server side handler by using the @HandlerChain annotation on the SEI or implementation class. Use one of several ways to configure a client side handler. You can configure a client side handler by using the @HandlerChain annotation on the generated service class or SEI. Additionally, you can programatically register your own implementation of the HandlerResolver interface on the Service, or programatically set the handler chain on the Binding object. |
|
javax.jws.SOAPBinding | The @SOAPBinding annotation specifies the mapping
of the Web service onto the SOAP message protocol. Apply this annotation to a type or methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint. The method level annotation is limited in what it can specify and is only used if the style property isDOCUMENT. If the method level annotation is not specified, the @SOAPBinding behavior from the type is used. |
|
Annotation class: | Annotation: | Properties: |
---|---|---|
javax.xml.ws.BindingType | The @BindingType annotation specifies the binding
to use when publishing an endpoint of this type. Apply this annotation to a server endpoint implementation class for a JavaBeans endpoint or a Provider endpoint. Important: • You can use the @BindingType annotation on the Java bean endpoint implementation class to enable MTOM by specifying either javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING or javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING as the value for the annotation. |
|
javax.xml.ws.RequestWrapper | The @RequestWrapper annotation supplies the JAXB
generated request wrapper bean, the element name, and the namespace for serialization
and deserialization with the request wrapper bean that is used at runtime. When starting with a Java object, this element is used to resolve overloading conflicts in document literal mode. Only the className attribute is required in this case. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint. |
|
javax.xml.ws.ResponseWrapper | The @ResponseWrapper annotation supplies the
JAXB generated response wrapper bean, the element name, and the namespace
for serialization and deserialization with the response wrapper bean that
is used at runtime. When starting with a Java object, this element is used to resolve overloading conflicts in document literal mode. Only the className attribute is required in this case. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint. |
|
javax.xml.ws.ServiceMode | The @ServiceMode annotation specifies whether
a service provider needs to have access to an entire protocol message or
just the message payload. Important: • The @ServiceMode annotation is only supported on classes that are annotated with the @WebServiceProvider annotation. |
|
javax.xml.ws.WebFault | The @WebFault annotation maps WSDL faults to
Java exceptions. It is used to capture the name of the fault during the serialization
of the JAXB type that is generated from a global element referenced by a WSDL
fault message. It can also be used to customize the mapping of service specific
exceptions to WSDL faults. This annotation can only be applied to a fault implementation class on the client or server. |
|
javax.xml.ws.WebServiceProvider | The @WebServiceProvider annotation denotes that
a class satisfies requirements for a JAX-WS Provider implementation class. Important: • A Java class that implements a Web service must specify either the @WebService or @WebServiceProvider annotation. Both annotations cannot be present. • The @WebServiceProvider annotation is only supported on the service implementation class. • Any class with the @WebServiceProvider annotation must have an operation named invoke. |
|
Annotation class: | Annotation: | Properties: |
---|---|---|
javax.annotation.Resource | The @Resource annotation marks a WebServiceContext
resource needed by the application. Apply this annotation to a server endpoint implementation class for a JavaBeans endpoint or a Provider endpoint. The container will inject an instance of the WebServiceContext resource into the endpoint implementation when it is initialized. |
|
javax.annotation.PostConstruct | The @PostConstruct annotation marks a method
that needs to be executed after dependency injection is performed on the class. Apply this annotation to a JAX-WS application handler, a server endpoint implementation class for a JavaBeans endpoint or a Provider endpoint. |
|
javax.annotation.PreDestroy | The @PreDestroy annotation marks a method that
must be executed when the instance is in the process of being removed by the
container. Apply this annotation to a JAX-WS application handler, a server endpoint implementation class for a JavaBeans endpoint or a Provider endpoint. |
|