REST in the Web3 Platform
One of the goals of the Web3 Platform was to adhere to as many of the architectural principles of REST that was possible. In our minds the key things were that:
1) Given a start URI and a description of all the content types and valid transitions a client could interact with the topic map store.
Yep, there is only that one point.
Given the URI of a topic map a client that is aware of the different content types that can be returned can interact with the entire topic map without guessing at, or constructing URIs.
For the Web3 Platform we introduced a new syntactic representation for Topic Maps because XTM is an interchange syntax for Topic Maps and not an effective Hypertext representation for the TMDM.
I’ll walk through some interactions starting from a topicmap URL to demonstrate why we introduced the new syntax and how a client behaves.
Starting with the topicmap URL:
[code]
GET http://localhost/web3/topicmaps/e518129d-b458-4171-99cc-5e4941dafc7b?format=xml
[/code]
When addressing Web3 Resources content negotiation can be done through accept headers or via a format parameter. The above GET returns the following representation.
[code]
[/code]
There are a couple of things to notice in this representation.
- We use full URLs for everything, no Ids that need turning into URLs based on some defined URL space.
- We are exposing the collections of Topics and Associations as resources in their own right. This allows clients to POST to these collections to create new Topics and Associations and also to fetch these collections. (The full representation documentation also specifies the allowed query parameters for these resources).
Now a client can navigate the topic collection using:
[code]
GET http://localhost/web3/topicmaps/e518129d-b458-4171-99cc-5e4941dafc7b/topics?format=xml
[/code]
This returns the following collection:
[code]
[/code]
The interesting things in the snippet above are:
- We have introduced a generic list container for topics, in fact topic refs. This gives us control over thing like collection size and paging.
- We have introduced a lightweight topic reference structure for use in listing topics. This is a subset of the full topic representation and is used in many places.
- We are explicit about the topic's web address.
- We provided explicit links to navigate through the collection All of the above means that a client who understands this content type can navigate to a topic, and find more results or the previous page of results. Following a link to a topic using: [code] GET http://localhost/web3/topicmaps/e518129d-b458-4171-99cc-5e4941dafc7b/topics/2a8a2182-f8b7-427a-9f7f-ef206b775606?format=xml [/code] Returns the following XML [code]
- The link to the associations for the topic. With this we have created a resource that can be navigated to return the associations in which the topic plays a role. (There are optional query parameters on this as well.)
- We use inline topic ref elements to minimise round trips for common things, such as property types and topic types.
- All contained resources, property (is name or occurrence) and identity expose their web address.
- We have also included version information to help with ETag processing.