Java Reference
In-Depth Information
As evident from the
@Stateless
annotation, the generated class is a stateless session
bean. The
@Path
annotation is used to identify the Uniform Resource Identifier
(URI) that our class will serve requests for. As we can see, several of the methods
in our class are annotated with the
@POST
,
@PUT
,
@DELETE
and
@GET
annotations.
These methods will be automatically invoked when our web service responds to
the corresponding HTTP requests. Notice that several of the methods are annotated
with the
@Path
annotation as well; this is because some of these methods require a
parameter. For example, when we need to delete an entry from the
CUSTOMER
table,
we need to pass the primary key of the corresponding rows as a parameter. The
format of the value attribute of the
@Path
annotation is
"{varName}"
, where the text
between the curly braces is known as a
path parameter
. Notice that the method has
corresponding parameters that are annotated with the
@PathParam
annotation.
Testing our RESTful web service
Once we deploy our project, we can make sure that the web service was deployed
successfully by expanding the
RESTful Web Services
node on our project,
right-clicking on our RESTful web service, and selecting
Test Resource Uri
: