Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introducing the Sample

The sample shows a basic REST-based Web Services using JAX-RS (JSR-311). The REST server provides the following services:   

Code Block
languagehtml/xml
<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:
Code Block
languagehtml/xml
<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.
Code Block
languagehtml/xml
<Customer>
   <name>Jack</name>
</Customer>
  •  A HTTP PUT request to URL ${serviceURL}/customers with following data updates the customer instance whose id is 123.
Code Block
languagehtml/xml
<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.