Java Reference
In-Depth Information
@javax.jws.WebService— Marks an interface or a class as being a web ser-
@javax.jws.soap.SOAPBinding— Configures the style (document/rpc)
along with the encoded (document encoded/literal)
With these two annotations, you can build a simple SOAP web service. Let's examine each
of the annotations individually.
Using the @WebService annotation
The @WebService annotation is used on a bean or an interface class. If you use this an-
notation on the bean class, the annotation processor or EJB container will generate the in-
terface for you. If you already have a bean interface, then you can mark the @WebSer-
vice annotation on the interface and the bean class will look like this:
public @interface WebService {
String name() default "";
String targetNamespace() default "";
String serviceName() default "";
String portName() default "";
String wsdlLocation() default "";
String endpointInterface() default "";
Using the @WebMethod annotation
The @javax.jws.WebMethod annotation is used to configure a method being exposed
as a web service. By default, on a class all methods are exposed as web services, so you'd
use this annotation to either exclude a method or configure properties of the exposed meth-
od such as the operation name or SOAP action. The full definition of this annotation is as
@ Retention(RetentionPolicy.RUNTIME)
@ Target({ElementType.METHOD})
public @interface WebMethod {
String operationName() default "";
String action() default "";
boolean exclude() default false;
Search WWH ::

Custom Search