Java Reference
In-Depth Information
TheSIB'smethodheadersaren'tannotated
@WebMethod
becausethisannotationis
typicallyusedinthecontextoftheSEI.However,ifyouweretoadda
public
meth-
od(whichconformstotherulesinSection5oftheJAX-RPC1.1specification) tothe
SIB,andifthismethoddoesn'texposeawebserviceoperation,youwouldannotatethe
method header
@WebMethod(exclude = true)
. By assigning
true
to
@We-
bMethod
's
exclude
element,youpreventthatmethodfrombeingassociatedwithan
operation.
Thiswebserviceisreadytobepublishedsothatitcanbeaccessedfromclients.
List-
in the context of the default lightweight HTTP server.
Listing 11-4.
Publishing TempVerter
import javax.xml.ws.Endpoint;
import ca.tutortutor.tv.TempVerterImpl;
class TempVerterPublisher
{
public static void main(String[] args)
{
Endpoint.publish("http://localhost:9901/tempverter",
new TempVerterImpl());
}
}
Publishing the web service involves making a single call to the
EndPoint
class's
Endpoint publish(String address, Object implementor)
class
method. The
address
parameter identifies the URI assigned to the web service. I've
chosentopublishthiswebserviceonthelocalhostbyspecifying
localhost
(equi-
valenttoIPaddress127.0.0.1)andportnumber9901(whichismostlikelyavailable).
Also, I've arbitrarily choosen
/TempVerter
as the publication path. The
imple-
mentor
parameter identifies an instance of TempVerter's SIB.
The
publish()
method creates and publishes an endpoint for the specified
im-
plementor
objectatthegiven
address
,andusesthe
implementor
'sannotations
tocreateWSDLandXMLSchemadocuments.Itcausesthenecessaryserverinfrastruc-
turetobecreatedandconfiguredbytheJAX-WSimplementationbasedonsomedefault