Java Reference
In-Depth Information
Figure6-1.Output of WebServiceRef InjectionServlet.java
That's all there is to it.
Discussion
There are two ways to use the
@WebServiceRef
annotation:
▪ Make your annotation refer to a generated service class. If the default value cannot be in-
ferred from the field or method your annotation modifies, then you must at a minimum
supply a value for the
type
property, which refers to the generated service class type.
▪ Make your annotation refer to an SEI. With this option, you must supply a service type
class object for the
value
property. This object must be a generated service class type (a
subtype of
javax.xml.ws.Service
).
The value of the
wsdlLocation
property will override the URL established in the generated
service class (the class annotated with
@WebService
).
WebServiceRefs
Annotations in Java prevent you from defining the same annotation more than once on the
same type. So if your client class needs to refer to more than one web service, you can use the
@WebServiceRefs
annotation to wrap multiple instances of
@WebServiceRef
. That curtails
the ability of JAX-WS to infer appropriate values for the name and type properties because
more than one
@WebServiceRef
is defined, and they are defined at the class level. To address
this, each
@WebServiceRef
annotation wrapped within a
@WebServiceRefs
annotation must
define
name
and
type
values.