Java Reference
In-Depth Information
doDelete() and doGet() readtheXMLfromtheconnection'sinputstreamand
output this XML content to the standard output device. Behind the scenes, the JAX-
WSinfrastructuremakesthestringofcharactersencapsulatedinthe StringReader
instance, which is encapsulated in the StreamSource instance returned from in-
voke() , available on the input stream.
doPost() and doPut() access the connection's output stream and output their
XMLcontenttothestream.Behindthescenes,JAX-WSmakesthiscontentavailableto
invoke() asaninstanceofaclassthatimplementsthe Source interface.Assuming
that the web service responds with a success code (200), each method reads the XML
replyfromtheconnection'sinputstreamandoutputsthiscontenttothestandardoutput
stream.
Compile Library.java ( javac Library.java ) and LibraryCli-
ent.java ( javac LibraryClient.java ). Run Library in one command
window ( java Library ) and LibraryClient in another command window
( java LibraryClient ). If all goes well, LibraryClient should generate the
following output:
<response>book inserted</response>
<response>book inserted</response>
<isbns><isb-
n>9781430210450</isbn><isbn>0201548550</isbn></isbns>
<book isbn="0201548550" pubyear="1992"><title>Advanced
C+</title><author>James O. Copli-
en</author><publisher>Addison Wesley</publisher></book>
<book isbn="9781430210450" pubyear="2008"><title>Beginning
Groovy and Grails</title><author>Christopher M. Jud-
d</author><author>Joseph
Faisal
Nusair-
at</author><author>James
Shin-
gler</author><publisher>Apress</publisher></book>
<response>book updated</response>
<book
isbn="0201548550"
pubyear="1992"><title>Advanced
Search WWH ::




Custom Search