Implementing a web service using an interface

All methods declared in our web service implementation class, CourseManagementService, are exposed as web service operations. However, if you want to expose only a limited set of methods from the web service implementation class, then you can use the Java interface. For example, if we want to expose only the getCourses method as a web service operation, then we can create an interface, let's say ICourseManagementService:

package packt.jee.eclipse.ws.soap; 
 
import java.util.List; 
 
import javax.jws.WebService; 
 
@WebService 
public interface ICourseManagementService { 
  public List<Course> getCourses(); 
} 

The implementation class also needs to be annotated with @WebService, with the endpointInterface ...

Get Java EE 8 Development with Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.