Java API for XML Web Services (JAX-WS)
Java API for RESTful Web Services (JAX-RS)
JAX-WS supports the Web Services Interoperability (WS-I) Basic Profile Version 1.1. The WS-I Basic Profile is a document that clarifies the SOAP 1.1 and WSDL 1.1 specifications to promote SOAP interoperability.
Creating a SimpleWeb Service and Clients with JAX-WS
The basic steps for creating a web service and client are as follows:
- Code the implementation class.
- Compile the implementation class.
- Package the files into aWARfile.
- Deploy theWARfile. The web service artifacts (wsdl, xsd), which are used to communicate with clients, are generated by the Application Server during deployment.
- Code the client class.
- Use a wsimport Ant task to generate and compile the web service artifacts (wsdl, xsd) needed to connect to the service. (Results of wsimport are auto-gen java classes)
- Compile the client class.
- Run the client.
Requirements of a JAX-WS Endpoint
- The implementing class must be annotated with either the javax.jws.WebService or the
javax.jws.WebServiceProvider annotation. - The implementing class may explicitly reference an SEI through the endpointInterface
element of the @WebService annotation but is not required to do so. If no endpointInterface is specified in @WebService, an SEI is implicitly defined for the implementing class. - The business methods of the implementing class must be public and must not be declared
static or final. - Business methods that are exposed to web service clients must be annotated with
javax.jws.WebMethod. - Business methods that are exposed to web service clients must have JAXB-compatible
parameters and return types. See the list of JAXB default data type bindings at
http://download.oracle.com/javaee/5/tutorial/doc/bnazq.html#bnazs. - The implementing class must not be declared final and must not be abstract.
- The implementing class must have a default public constructor.
- The implementing class must not define the finalize method.
- The implementing class may use the javax.annotation.PostConstruct or the
javax.annotation.PreDestroy annotations on its methods for lifecycle event callbacks. The @PostConstruct method is called by the container before the implementing class begins responding to web service clients. The @PreDestroy method is called by the container before the endpoint is removed from operation.