@WebService Annotation



The @javax.jws.WebService annotation marks a Java class or interface as being a web service.

@WebService
public class ATMValidator {...}


And the following snippet shows the annotation on an interface implemented by a class. As you can see, the implementation needs to define the fully qualified name of the interface in the endpointInterface attribute:

@WebService
public interface Validator {...}


@WebService(endpointInterface = "com.data.soapws.ATMValidator")
public class ATMValidator implements Validator {...}


The @WebService annotation has a set of attributes that allow you to customize the name of the web service in the WSDL file (the <wsdl:portType> or <wsdl:service> element) and in its namespace, as well as
change the location of the WSDL itself (the wsdlLocation attribute).
 

The @WebService API

@Retention(RUNTIME) @Target(TYPE)
public @interface WebService {
String name() default "";
String targetNamespace() default "";
String serviceName() default "";
String portName() default "";
String wsdlLocation() default "";
String endpointInterface() default "";
}


So when the default WSDL mapping rules are not appropriate for your SOAP web service, just use the needed attributes. The code below changes the port and service name:

@WebService(portName = "ATMDataValidator", serviceName = "ATMValidatorService")
public class CardValidator {...} 


When you use the @WebService annotation, all public methods of the web service are exposed except when using the @WebMethod annotation.



Ref : Beginning of JavaEE 7