Java Reference
In-Depth Information
The following annotation types (three of which are deprecated in favor of using the
HandlerChain
annotation type) belong to the
javax.jws.soap
package:
•
InitParam
describesaninitializationparameter(aname/valuepairpassedto
the handler during initialization). This annotation type is deprecated.
•
SOAPBinding
specifiesthemappingofthewebserviceontotheSOAPpro-
tocol.
•
SOAPMessageHandler
specifies a single SOAP message handler that runs
before and after the web service's business methods. This handler is called in
response to SOAP messages targeting the service. This annotation type is de-
precated.
•
SOAPMessageHandlers
specifiesalistofSOAPprotocolhandlersthatrun
beforeandafterthewebservice'sbusinessmethods.Thesehandlersarecalled
inresponsetoSOAPmessagestargetingtheservice.Thisannotationtypeisde-
precated.
Finally,
javax.xml.ws
's most important annotation types from a RESTful web-
service perspective are
WebServiceProvider
and
Binding
. I will discuss these
annotation types later in this chapter.
Web Service Tools
Java provides four command-line-based tools that facilitate web service development.
Two of these tools are used to convert between XML Schema-based schemas (see
documents:
•
schemagen
:WSDLdocumentsuseXMLSchemadatatypestodescribeweb
service function returnandparameter types.Thistoolgenerates aschema (of-
tenstoredinafilewitha
.xsd
extension)fromJavaclasses—oneschemafile
is created for each referenced namespace. After the schema has been created,
XML instance documents
(XML documents that adhere to their schemas) can
beconvertedtoandfromJavaobjectsviaJAXB.Theclassescontainallthein-
formationneededbyJAXBtoparsetheXMLfor
marshaling
(convertingJava
objectstoXML)and
unmarshaling
(convertingXMLtoJavaobjects)—theap-
plication doesn't perform XML parsing.
•
wsgen
: This tool reads a compiled web service endpoint interface and gen-
erates JAX-WS portable artifacts for web service deployment and invocation.
It can alternatively generate a WSDL file and corresponding XML Schema
document (when its
-wsdl
option is specified). This tool isn't required when