Java Reference
In-Depth Information
bespecifiedasaURI,whichhappenstobe
http://localhost:9902/library
in this example.
After adding a port to the
Service
object,
doGet()
invokes
createDis-
patch()
as explained earlier. Once again, a
QName
object with an empty qualified
name is passed because there is no WSDL to indicate a port name.
The returned
Dispatch<Source>
object's
Map<String,Object>
getRequestContext()
method (which
Dispatch
inherits from its
Bind-
ingProvider
superinterface) is called to obtain the context that is used to initialize
the message context for request messages.
doGet()
inserts the request method verb
(
GET
) and query string (
isbn=
isbn
) into this map, which will be made available to
the provider.
At this point,
doGet()
executes
Source result = dis-
patch.invoke(null);
,passing
null
insteadofa
Source
objectasanargument
becausetheprovider's
doGet()
methodexpectstoreceiveitsdataasaquerystring.If
anexceptionoccursduringtheinvocation,acatchblockoutputstheexceptioninforma-
tionandexits
doGet()
.Otherwise,the
result
object'sXMLcontentistransformed
intoa
DOMResult
object,whichisprocessedvia
XPath
expressionstoobtainresult
data, which is then output.
youweretousethesamebook-relateddatapresentedearlierinthischapter,youwould
observe the following output:
<response>book inserted</response>
<response>book inserted</response>
9781430210450
0201548550
Title: Advanced C+
Author: James O. Coplien
ISBN: 0201548550
Publication Year: 1992
Publisher: Addison Wesley
Title: Beginning Groovy and Grails
Author: Christopher M. Judd