Java Reference
In-Depth Information
isn'tnecessarywhendeclaring c2f() and f2c() .Thesemethodsareimplicitly pub-
lic .
Eachof c2f() and f2c() isalsoannotated @WebMethod .Although @WebMeth-
od is not essential in this example, its presence reinforces the fact that the annotated
method exposes a web service operation.
Listing 11-3 presents the web service's TempVerterImpl class.
Listing 11-3. TempVerter's Service Implementation Bean
package ca.tutortutor.tv;
import javax.jws.WebService;
@WebService(endpointInterface
=
"ca.tutortutor.tv.tempverter")
public class TempVerterImpl implements TempVerter
{
public double c2f(double degrees)
{
return degrees*9.0/5.0+32;
}
public double f2c(double degrees)
{
return (degrees-32)*5.0/9.0;
}
}
TempVerterImpl describesa Service Implementation Bean (SIB) ,whichprovides
an implementation of the SEI. This class is declared to be a SIB via the @WebSer-
vice(endpointInterface = "ca.tutortutor.tv.tempverter") an-
notation.The endpointInterface elementconnectsthisSIBtoitsSEI,andisne-
cessarytoavoidundefinedporttypeerrorswhenrunningtheclientapplicationpresen-
ted later.
The implements TempVerter clauseisn'tabsolutelynecessary.Ifthisclauseis
not present, the TempVerter interface is ignored (and is redundant). However, it's a
good idea to keep implements TempVerter so the compiler can verify that the
SEI's methods have been implemented in the SIB.
Search WWH ::




Custom Search