Java Reference
In-Depth Information
thisdocument,tofacilitatecreatingtheclient.InthecontextofTempVerter,youwould
use this tool as follows:
wsimport -keep -p client http://localhost:9901/TempVert-
er?wsdl
wsimport outputs “parsing WSDL…”, “Generating code…”, and “Compiling
code…”messages;andgeneratestheclassfilesthataclientneedstoaccessthiswebser-
vice.The -keep optioncauses wsimport tosavethesourcecodefortheseclassfiles
aswell,whichhelpsuslearnhowclientsaccessthewebservice,andmakesitpossible
to add client-side handlers for intercepting messages (discussed later in this chapter).
The -p optionidentifiesthepackagedirectoryinwhichtostorethegeneratedsource
and/orclassfiles.Youcanspecifyanymeaningfulname(suchas client )and wsim-
port will create a package directory with this name, and store the package directory
structure underneath.
Caution If you don't specify -p and the current directory contains TempVerter's
package directory structure, Listing 11-2 ' s TempVerter interface source code (and
theclassfile)willbeoverwrittenwiththecontentsofagenerated TempVerter.java
source file (and classfile).
Alongwithclassfiles, wsimport stores TempVerter.java , TempVerterIm-
plService.java ,andothersourcefilesinthe client directory.Theformersource
file'sJavainterfacedeclaresthesamemethodsas Listing11-2 ' s TempVerter SEIin-
terface, but with c2F and f2C method names replacing c2f and f2c , to adhere to a
JAXB naming convention where the first letter of each subsequent word in a method
name is capitalized.
Thelatterfile'sclass,whichispresentedin Listing11-8 , providesanoargumentcon-
structorforinstantiatingthisclass,anda getTempVerterImplPort() methodthat
returnsaninstanceofthegenerated TempVerter interface;theclientexecutestheweb
service's operations on this instance.
Listing 11-8. A cleaned up service implementation class for accessing the TempVerter web service
package client;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
Search WWH ::




Custom Search