August 2013
Intermediate to advanced
360 pages
10h 47m
English
JAX-WS, like JAX-RS, uses annotations, and machine-generated JAX-WS code is awash with these. The first example is stingy in its use of annotations in order to underscore exactly what is required for a SOAP-based service. Later examples introduce additional annotations.:
The RandService class (see Example 4-1) defines a SOAP-based service with two operations, each an annotated Java method:
Example 4-1. A SOAP-based service with two operations
packagerand;importjavax.jws.WebService;importjavax.jws.WebMethod;importjava.util.Random;@WebService![]()
publicclassRandService{privatestaticfinalintmaxRands=16;@WebMethod// optional but helpful annotation![]()
publicintnext1(){returnnewRandom().nextInt();}@WebMethod// optional but helpful annotation![]()
publicint[]nextN(finalintn){finalintk=(n>maxRands)?maxRands:Math.abs(n);int[]rands=newint[k];Randomr=newRandom();for(inti=0;i<k;i++)rands ...
Read now
Unlock full access