Java Reference
In-Depth Information
Using Curl to Run the customer Example Application
Curl is a command-line tool you can use to run the customer application on UNIX plat-
forms. You can download Curl from http://curl.haxx.se or add it to a Cygwin
installation.
Run the following commands in the directory tut-install /examples/jaxrs/cus-
tomer/ after deploying the application.
To add a new customer and test the POST method using XML data, use the following
command:
Click here to view code image
curl -i --data @sample-input.xml \
--header Content-type:application/xml \
http://localhost:8080/customer/rest/Customer
To add a new customer using JSON data instead, use the following command:
Click here to view code image
curl -i --data @sample-input.json \
--header Content-type:application/json \
http://localhost:8080/customer/rest/Customer
A successful POST returns HTTP Status: 201 (Created) .
To retrieve the details of the customer whose ID is 1, use the following command:
curl -i -X GET http://localhost:8080/customer/rest/Customer/1
To retrieve the details of the same customer represented as JSON data, use the following
command:
Click here to view code image
curl -i --header Accept:application/json
-X GET http://localhost:8080/customer/rest/Customer/1
A successful GET returns HTTP Status: 200 (OK) .
To delete a customer record, use the following command:
curl -i -X DELETE http://localhost:8080/customer/rest/Customer/1
A successful DELETE returns HTTP Status: 204 .
Search WWH ::




Custom Search