The Address Book sample is an example of a RESTful service that stores/retrieves/removes/updates address book entries. Additionally, a client interface, written with DOJO, is provided to manipulate and view the address book.
The path to the AddressBook resource is declared by the @Path annotation.
|
The AddressBook has seven methods of interest:
This method maps to incoming GET requests whose request path is of the form '/addresses'
|
This method maps to incoming POST requests whose request path is of the form '/addresses' and the Content-Type is "application/x-www-form-urlencoded". The information to create a new address instance is contained in the posted form.
|
This method maps to incoming POST requests whose request path is of the form '/addresses' and the Content-Type is "text/xml". The information to create a new address instance is contained in the posted xml.
|
This method maps to incoming DELETE requests. The request path will be of the form '/addresses/{address_entry_name}'
|
This method maps to incoming PUT requests whose request path is of the form '/addresses'. The information to update an address instance is contained in the query string.
|
This method maps to incoming GET requests to search for an address instance. The request path will be of the form '/addresses/search/{search_string}'
|
This method maps to incoming requests, other than DELETE requests, whose request path is of the form '/addresses/{address_entry_name}'.
|
This method will delegate requests to the Address subresource. The Address subresource has a single method to serve GET requests:
|
Here's a brief summary of the resource:
HTTP Method | URI | Input Type(s) | Output Type(s) | Note(s) |
---|---|---|---|---|
GET | /addresses | */* | text/xml, application/json | Get all addresses |
POST | /addresses | application/x-www-form-urlencoded | n/a | Add a new address |
POST | /addresses | text/xml | n/a | Add a new address |
DELETE | /addresses/{entryName} | text/xml, application/x-www-form-urlencoded | n/a | Remove the specified address |
PUT | /addresses | text/xml, application/x-www-form-urlencoded | n/a | Update an existing address |
GET | /addresses/search/{searchString} | text/xml, application/x-www-form-urlencoded | text/xml, application/json | Get addresses whose entry matches 'searchString' |
GET | /addresses/{entryName} | text/xml, application/x-www-form-urlencoded | text/xml, application/json | Delegate to GET on Address class, retrieve specified address |
The address book client presents a web interface that allows you to manipulate the Address Book Resource:
Get the list of current addresses using HTTP GET
|
Add a new address using HTTP POST (with form data)
|
Add a new address using HTTP POST (with xml)
|
Get a specific address using HTTP GET
|
Update the street address using HTTP PUT
|
Search for an address that starts with "foo"
|
Search for address for "fooBar" and get back JSON
|
Delete address for "fooBar"
|