Versions Compared

Key

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


  • Sample location - <AS_HOME>/samples/Jaxws-Jaxrs/jaxrs_starbucks_service
  • Sample webapp name - jaxrs_starbucks_service.war

...

This sample shows some advanced functionalities of REST-based Web Services using JAX-RS (JSR-311). Please note that this sample was called jaxrs_sample_02 in the AS 5.1.0 release. It has been renamed to provide better clarity. This JAX-RS webapp provides following services:    

  • A RESTful Starbucks outlet service is provided on URL http://localhost:9763/jaxrs_starbucks_service/services/Starbucks_Outlet_Service (say serviceURL). Users access this URI to perform operations of drink orders.      
  • A HTTP GET request to URL ${serviceURL}/orders/123 returns a drink order added with the generated id 123. The JSON document returns: 

    Code Block
    languagejava
    {
       "Order":{
           "orderId":"123",
           "drinkName":"Vanilla Flavored Coffee",
           "additions":"Milk",
           "locked":false
       }
    }
    
  • A HTTP POST request to URL ${serviceURL}/orders  with the following data adds an order. 

    Code Block
    languagehtml/xml
    <Order>
       <drinkName>Mocha Flavored Coffee</drinkName>
       <additions>Caramel</additions>
    </Order>
  • An id for this order is generated at server-side and returned in the response.   The response body looks like the following in JSON format. 

    Code Block
    {"Order":{
       "additions":"Caramel",
       "drinkName":"Mocha Flavored Coffee",
       "locked":false,
       "orderId":"ee1a9ec2-c8a5-4afe-8585-74df591f9990"
    }}
  • A HTTP PUT request to URL ${serviceURL}/orders with the following data, where the 'orderId' is set to the one received in the response body when the order was added: 

    Code Block
    {
       "Order":{
           "orderId":"ee1a9ec2-c8a5-4afe-8585-74df591f9990",
           "additions":"Chocolate Chip Cookies"
       }
    }
  • It updates the 'additions' of the order "ee1a9ec2-c8a5-4afe-8585-74df591f9990" from "Caramel" to "Chocolate Chip Cookies". The response will be in XML-format as follows.

    Code Block
    languagehtml/xml
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
       <Order>
          <additions>Chocolate Chip Cookies</additions>
          <drinkName>Full Leaf Green Tea</drinkName>
          <locked>true</locked>
          <orderId>ee1a9ec2-c8a5-4afe-8585-74df591f9990</orderId>
       </Order>
  • A HTTP DELETE request to URL ${serviceURL}/orders/ee1a9ec2-c8a5-4afe-8585-74df591f9990 with an empty request body will delete the order details of order "ee1a9ec2-c8a5-4afe-8585-74df591f9990".

...