Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This sample demonstrates 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:

    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>

...

This sample can be found at  <AS_HOME>\samples\Jaxws-Jaxrs\jaxrs_basic

For information on building and running the sample, see Building and Running JAX-RS Samples.