Java Reference
In-Depth Information
the body, any attachments, and so on. A
DataSource
works with HTTP bindings to provide
an abstraction of an arbitrary collection of data, providing access to the data in the form of
InputStream
and
OutputStream
.
Working with a
Provider
requires detailed knowledge of the structure of the payload or mes-
sage.
Creating a Provider<T>
To create a provider, you must do three things:
1. Supply a public no-arg constructor.
2. Implement the
Provider<T>
interface, supplying one of the three acceptable values for
the type parameter.
3. Annotate the class with the
@WebServiceProvider
annotation.
Along with the
@WebServiceProvider
interface, the developer can supply a
@javax.xml.ws.Service.Mode
annotation with one of two values:
Mode.PAYLOAD
or
Mode.MESSAGE
. This value indicates the view of the data the provider instance will have ac-
cess to.
Using
Mode.PAYLOAD
will give the provider access to only the children of the SOAP body ele-
ment. Using
Mode.MESSAGE
gives the provider the entire SOAP envelope, including headers.
Note that here my example uses SOAP, but the
MESSAGE
mode is actually intended in a more
general way, meaning that it applies to the protocol message itself, whatever that protocol is.
The default value is
PAYLOAD
.
NOTE
With a provider, you are also allowed to use handlers. Handlers are discussed further in
Implementing
that it conforms to that WSDL using the
wsdlLocation
property. Because the provider is not
an EJB, you'll just package this in a WAR, and have your Ant script place the WSDL in the
WEB-INF/wsdldirectory. Your service interface indicates that a request should contain a user-
name, and if the service authorizes the user, it will return an SSO token placed in the header
as well as a child of the SOAP body indicating the role that user is in.
Example7-10.The WSDL for an authorizer service