JAX-RS Demo - Sample 02 
=======================

The demo shows some advanced functionalities of REST based Web Services using JAX-RS (JSR-311). The REST server provides the 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 an drink order added with the generated id of 123. The JSON document returned:

{
    "Order":{
        "orderId":"123",
        "drinkName":"Vanilla Flavored Coffee",
        "additions":"Milk",
        "locked":false
    }
}

--------------------------------------
A HTTP POST request to URL ${serviceURL}/orders
with the data:

<Order>
    <drinkName>Mocha Flavored Coffee</drinkName>
    <additions>Caramel</additions>
</Order>

adds an order. An id for this order is generated at server side, and is returned in the response. The response body would look like the following in JSON format.

{"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 data where the orderId is set to the one we received in the response body when we added the order :

{
    "Order":{
        "orderId":"ee1a9ec2-c8a5-4afe-8585-74df591f9990",
        "additions":"Chocolate Chip Cookies"
    }
}

will update the 'additions' of the order ee1a9ec2-c8a5-4afe-8585-74df591f9990 from "Caramel" to "Chocolate Chip Cookies". The response would be in XML-format like follows.

<?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 empty request body,

will delete the order details of order ee1a9ec2-c8a5-4afe-8585-74df591f9990.

--------------------------------------


The client code demonstrates how to send HTTP GET/POST/PUT/DELETE request. The 
server code demonstrates how to build a RESTful endpoint through 
JAX-RS (JSR-311) APIs.


Please review the README in the samples directory before
continuing.



Building and running the demo using maven
---------------------------------------

From the base directory of this sample (i.e., where this README file is
located), the maven pom.xml file can be used to build and run the demo. 


Using either UNIX or Windows:

  * mvn clean install (builds the demo and creates a WAR file)
  * Start the server (run bin/wso2server.sh/.bat)
  * mvn -Pdeploy (deploys the generated WAR file on WSO2 AppServer with related logs on the console)
  * mvn -Pclient (runs the client)

To remove the target dir, run `mvn clean`.



Building and running the demo using ant
---------------------------------------

1. Run "ant" on AS_HOME/samples/Jaxws-Jaxrs/jaxrs_starbucks_service directory. This will deploy the jaxrs_starbucks_service
   service in WSO2 AS.
2. Start the server and access the Management Console at https://localhost:9443/carbon. Go to
   the service listing page. You will see the deployed jaxrs_starbucks_service service.
3. Execute "sh run-client.sh" to run the client.
4. Try the sample with different QoS options. Run "sh run-client.sh -help" for different options.

Please download the Documentation Distribution and refer to the jaxrs_starbucks_service sample document
for detailed instructions on how to run the jaxrs_starbucks_service sample.


