Java Reference
In-Depth Information
chooseaviewer—youwillalsoobservethisMIMEtypein ImagePublisher 'scom-
mand window.
The reason for this change of MIME type has to do with Mime-
typesFileTypeMap 's String getContentType(String filename)
method.Atsomepoint,thismethodiscalledtoreturnthecontenttypeforthespecified
filename. When this name is missing an extension, or when a MIME type for the
file's extension has not been registered (via a call to addMimeTypes() ), getCon-
tentType() returns the default application/octet-stream MIME type.
Youmightwanttokeepthisscenarioinmindwhencustomizing ImagePublisher
(andaclient)toworkwiththeHTTP Accept requestheader.(Theclientspecifiesan
Accept header[via URLConnection 's void setRequestProperty(String
key, String value) method]withoneormoreMIMEtypesthattelltheserver
whatkind(s)ofdatatheclientwantstoreceive;theserverexaminesthisheaderandre-
turns this data when the header includes a MIME type that the server can honor.)
Note If you're wondering why @ServiceMode(value =
javax.xml.ws.Service.Mode.MESSAGE) is specified in Listing 11-23 , the
answer is that Provider<DataSource> is used for sending attachments, which
means that javax.xml.ws.Service.Mode.PAYLOAD mode is invalid.
Providers and Dispatch Clients
This chapter presents high-level and low-level approaches to working with JAX-WS.
The high-level approach requires you to work with SEIs and SIBs; it simplifies and
hidesthedetailsofconvertingbetweenJavamethodinvocationsandtheircorresponding
SOAP-basedXMLmessages.Thelow-levelapproachletsyouworkdirectlywithXML
messages, and must be followed to implement a RESTful web service.
While discussing how to implement a RESTful web service with JAX-WS, I intro-
ducedyoutothisAPI's Provider<T> interface,whose invoke() methodiscalled
byaclienttoreceiveandprocessarequest,andtoreturnaresponse.Ithendemonstrated
howaclientcommunicateswithaproviderbyusingthe HttpURLConnection class.
Behindthescenes,theJAX-WSruntimetakestheinformationreceivedfromtheURL
connectionandcreatestheproperobjecttopassto invoke() .Italsotakestheobject
returned from invoke() and makes its contents available to the client via the URL
connection's output stream.
JAX-WSalsooffersthe javax.xml.ws.Dispatch<T> interfaceasaclient-side
companionto Provider .Aclientuses Dispatch toconstructmessagesormessage
Search WWH ::




Custom Search