Java Reference
In-Depth Information
C++</title><author>James O. Copli-
en</author><publisher>Addison Wesley</publisher></book>
<response>book deleted</response>
<isbns><isbn>9781430210450</isbn></isbns>
Run
LibraryClient
asecondtimeandyoushouldobservethatthesecond
<re-
sponse>book inserted</response>
message has been replaced with
can-
not insert book: 400
. This message is output because the
library
map
already contains an entry whose key identifies ISBN 9781430210450.
Note
When you rerun
LibraryClient
and observe the
cannot insert
book: 400
message,youmightalsoobservestrange
Library
output.Specifically,
you might notice a thrown exception whose first line begins with the date and time
and continues with
com.sun.xml.internal.ws.server.provider.SyncProviderInvokerTube
processRequest
,whosesecondlineconsistsof
SEVERE: null
,andwhosethird
lineconsistsof
javax.xml.ws.http.HTTPException
.Thisstrangeoutputres-
ultsfrom
doPost()
detectinganattempttoreinsertabookthathasalreadybeenin-
serted, and then throwing
HTTPException
to
Library
's
invoke()
method,
whichisthenthrownoutof
invoke()
—it'slegaltothrowthisexceptionoutof
in-
voke()
,whichisdocumentedtothrow
WebServiceException
(and
HTTPEx-
ception
isadescendentofthisclass).WhenIfirstdetectedthisproblem,Icontacted
Oracle(acoupleofdaysbeforeJava7wastobereleased)andwastoldtosubmitabug
report.Isubmitted“BugID:7068897-StrangeerrorwhenthrowingHTTPException
fromProvider<Source>invoke()method”andthisbugreportremainedforacoupleof
days before strangely disappearing. Perhaps I've experienced an anomaly peculiar to
running
Library
onWindowsXPServicePack3.However,thismightbeagenuine
Java bug.
Accessing Google's Charts Web Service
Accessingsomeoneelse'sRESTfulwebserviceiseasierthancreatingyourownbecause
you can forget about JAX-WS and deal only with
HttpURLConnection
to make a
request and retrieve the necessary data. Furthermore, youaren't restricted to retrieving
XML data. For example, Google's RESTful Charts web service (
ht-