Introducing the Sample
The sample shows a basic REST-based Web Services using JAX-RS (JSR-311). The REST server provides the following services:
- A RESTful customer service is provided on URL http://localhost:9763/jaxrs_basic/services/customers/customerservice (say serviceURL). Users access this URI to operate on customer.
- A HTTP GET request to URL ${serviceURL}/customers/123 returns a customer instance whose id is 123. The XML document returns the following:
<Customer> <id>123</id> <name>John</name> </Customer>
- A HTTP GET request to URL ${serviceURL}/orders/223/products/323 returns product 323 that belongs to order 223. The XML document returns the following:
<Product> <description>product 323</description> <id>323</id> </Product>
- A HTTP POST request to URL ${serviceURL}/customers with the following data adds a customer whose name is Jack.
<Customer> <name>Jack</name> </Customer>
- A HTTP PUT request to URL ${serviceURL}/customers with following data updates the customer instance whose id is 123.
<Customer> <id>123</id> <name>John</name> </Customer>
The client code demonstrates how to send HTTP GET/POST/PUT/DELETE requests whereas the server code demonstrates how to build a RESTful endpoint through JAX-RS (JSR-311) APIs.