The product provides a Hello World sample that demonstrates a simple Representational State Transfer (REST) application using the IBM® Java™ API for RESTful Web Services (JAX-RS) implementation.
The following table lists the required prerequisites for the Hello World sample.
Product prerequisite | Version |
---|---|
Java Technology Edition | 5.0 or 6.0 |
Java 2 Platform, Enterprise Edition (J2EE) 1.4 or Java Enterprise Edition 5 (Java EE) application server | WebSphere® Application Server Version 6.1.0.x |
The Hello World sample application demonstrates a simple REST application using the IBM JAX-RS implementation. The sample includes two independent Web archive (WAR) files. One Web module uses the IBM JAX-RS servlet to service requests while the other module uses the IBM JAX-RS filter to service requests. While both Web modules provide simple Hello World services, the two modules demonstrate the differences using the JAX-RS servlet and the filter. You can choose to use either the servlet or the filter when developing your RESTful services. The source code for the sample is packaged with the enterprise archive (EAR) application.
Also provided with the Hello World sample is a stand-alone Java client. This client is a simple client that posts and retrieves information from the Hello World service. The source code is packaged with the JAR file.
By default, you can install the EAR application with minimal configuration. A Web module that uses the IBM JAX-RS servlet has been preconfigured with a context root of /restservlet. A Web module that uses the IBM JAX-RS filter has been preconfigured with a context root of /restfilter.
During the installation of the Feature Pack for Web 2.0, you can choose to install the IBM JAX-RS samples. Use the following instructions to install the sample outside of the product installation process.
You have completed the installation of the Hello World sample.
You can now begin using Hello World sample, which demonstrates the configuration of services using the IBM JAX-RS server runtime and the use of a stand-alone Apache Wink client.
Contents of the Hello World sample
There are two separate Web modules in the sample application. One of the Web modules uses the JAX-RS servlet and the other uses the JAX-RS filter. Depending on the needs of your test application, you can choose to use either the servlet or the filter. The configuration differences between the two Web modules are primarily in the web.xml file.
Both Web modules expose a simple resource with a JAX-RS @Path value of helloworld. In this sample application, the resource representation is a plain text string. You can retrieve the representation of the resource by issuing an HTTP GET method to the appropriate URL. You can also use an HTTP PUT or POST method to change the representation of the resource and use an HTTP DELETE method to remove the representation.
The servlet version of the Web module for this sample has a context root value of restservlet. In the web.xml file for the Web module, the URL pattern is restapi/*. Therefore, all resources in the Web module have a URL prefix of http://<hostname>:<port>/restservlet/restapi.
If the installation of this product is completed on a local machine, issuing an HTTP GET command to http://localhost:9080/restservlet/restapi/helloworld using either the sample stand-alone Java client or a Web browser, returns a simple string value.
The filter version of the Web module for this sample has a context root value of restfilter. In the web.xml file for the Web module, the URL pattern is /*. Therefore, all resources in the Web module have a URL prefix of http://<hostname>:<port>/restfilter/. For more information, see the configuring the web.xml filter documentation for details on the differences between the servlet and filter.
java -jar ibm-sample-helloworld-client.jarThe stand-alone client issues requests to the service.
In this information ...Related concepts
| IBM Redbooks, demos, education, and more(Index) |