The RandService in Two Files
The RandService in the first example (see Example 4-1) combines, in a single source file,
what JAX-WS calls the SEI (Service Endpoint Interface) and
the SIB (Service Implementation Bean). The SEI specifies, at a high level that befits an interface,
the service operations, and the SIB provides an implementation of the operations. A SIB can be one of the following:
-
A POJO class such as
RandServiceannotated as@WebServiceand encapsulating service operations, each annotated as a@WebMethod. -
A
@StatelessSession EJB that is likewise annotated as a@WebService. EJBs in general predate JAX-WS; hence, this second type of SIB is an inviting way to expose legacy EJBs as web services.
Chapter 7 covers the EJB implementation of a @WebService.
For now, the SIBs will be POJO classes. For convenience, most of my examples take the
single-file approach, which combines the SEI and the SIB into one class annotated as
a @WebService. The two-file approach is illustrated with the SEI RandService (see Example 4-4)
in one file and the SIB RandImpl (see Example 4-5) in another file. The RandService is now an
interface, whereas the RandImpl is a class that implements this interface.
Example 4-4. The Service Endpoint Interface for the revised RandService
packagerand2;importjavax.jws.WebService;importjavax.jws.WebMethod;importjava.util.Random;@WebServicepublicinterfaceRandService{@WebMethodpublicintnext1();@WebMethodpublicint[]nextN(finalintn);}
Example 4-5. The ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access