For a full tutorial that shows how to
work with RESTful web services,
see:
You can use NetBeans IDE to create a RESTful web service in a Java Web application. You can use the IDE to create
either an "empty" service based on a pattern (singleton or item/container) or a service configured to communicate with
an existing database. In addition, you can expose any suitable Java class as a RESTful web service by
appending it appropriately.
In the Projects window or Files window, right-click the web application project node
and choose New. Then choose one of the following:
RESTful Web Service from Database. This wizard creates entity classes
from a database and then creates RESTful web services from those entity classes.
Note: If you do not have existing entity classes, it is
safer and more convenient to use this wizard instead of the Entity Classes From
Database wizard followed by the RESTful Web Services from Entity Classes wizard.
RESTful Web Services from Entity Classes. Creates RESTful web services from a set of existing entity classes.
RESTful Web Services from Patterns.
Creates RESTful web services using one of the following patterns:
Simple Root Resource. Creates a RESTful root resource
class with GET and PUT methods. This pattern is useful for creating
a simple HelloWorld service and wrapper services for invoking
WSDL-based web services.
Container-Item. Creates a pair of RESTful resource
classes, consisting of an item resource class and its container
resource class.
Item resources can be created and added to the container resource
using the POST method on the container resource class. Note
that the URI for the newly created item resource is determined
by the container resource.
Client-Controlled Container-Item. Creates a pair of RESTful
resource classes, consisting of an item resource class and its container
resource class.
This pattern is a slight variation of the Container-Item pattern.
The difference is that there is no POST method on the container
resource class for creating item resources. Instead, item resources
are created using the PUT method on the item resource class.
The reason this is called Client-Controlled Container-Item pattern
is because the URI for the item resource is determined by the client
and not the container resource.
Alternatively, you can choose the above templates
by right-clicking the project node, choosing New > Other
and then selecting them from the Web Services category.