Web service endpoint implementation class is used by the Web service client to access a stateless session bean. It is typically the primary programming artifact for enterprise bean Web service endpoints. It declares the methods that a client can invoke on the service. An interface is not required while building a JAX-WS endpoint. The Web service implementation class implicitly defines an SEI (service endpoint implementation). A Web service endpoint implementation class must conform to the following rules:
It must be annotated with either the javax.jws.WebService or javax.jws.WebServiceProvider annotations.
It 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 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.
It must not be declared final and must not be abstract.
It must have a default public constructor.
The endpoint class must be annotated @Stateless.
It must not define the finalize method.
It may use the javax.annotation.PostConstruct or javax.annotation.PreDestroy annotations on its methods for life-cycle event callbacks.
The @PostConstruct method is called by the container before the class begins responding to Web service clients.
The @PreDestroy method is called by the container before the endpoint is removed from operation.
For example:
package bookaccount;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebService;
@Stateless
@WebService
public class BookAccountBean implements BookAccount {
private String message = “Hello, “;
public void BookAccountBean() {}
@WebMethod
public String sayBook(String name) {
return message + name + “.”;
}
}
BookAccount is the Web service endpoint interface and the class that implements this interface must implement the sayBook() method defined by the BookAccount interface. The interface decouples the implementation class from the type of client access. For example, if a remote and home interface is added to a class named BookAccountBean, the methods of the BookAccountBean class could also be accessed by remote clients. The BookAccountBean class implements the sayBook method, which is annotated @WebMethod annotation.
Responses to “What is a Web service endpoint implementation class?”