Java Reference
In-Depth Information
Creating a Service Provider with an XML View
Problem
You want to create a service implementation that works directly with the SOAP XML in the
requests and responses, rather than the object view.
Solution
Have your service implement the javax.xml.ws.Provider<T> interface.
Discussion
JAX-WS-based web services are typically implemented using annotations, which allow the
developer to get up and running quickly. Such endpoint implementations are very easy to work
with and save developers the trouble of having to deal with a lot of plumbing. They offer an
object-level view of messages and port types as described in the WSDL, allowing developers
to work comfortably with abstractions over the XML contents of the messages passed back
and forth in service invocations.
But there are times when you want to have a raw XML view of the requests and responses
coming through your service. That's where Provider<T> comes in.
Provider<T> is part of JAX-WS, but it lets you work with the SAAJ API, and it offers an al-
ternative to working with annotated SEIs. It is the server-side analog to Dispatch<T> , provid-
ing an XML message-level view of requests. The interface defines a single method for you to
implement:
T invoke(T request)
Every time a new message is received, the invoke method is called.
Vendor implementations of JAX-WS are required to support at least three values for the type
parameter on the provider:
javax.xml.transform.Source
javax.activation.DataSource
javax.xml.soap.SOAPMessage
A Source acts as a container for XML source, and it can include implementations such as
DOMSource and SAXSource . SOAPMessage represents a SOAP message containing the header,
Search WWH ::




Custom Search