Web Application Interaction Format (WAIF)

Last updated on 27 July, 2005

This Version
http://iandavis.com/2005/web-description/waif-20050727
Latest Version
http://iandavis.com/2005/web-description/waif-20050727
Previous Version
None
Author
Ian Davis (http://purl.org/NET/iand)

Abstract

This specification describes the Web Application Interaction Format (WAIF). WAIF is designed for describing interactions with web applications, particularly those using XML as a representation format.

Introduction

This document describes the Web Application Interaction Format (WAIF). The main goals of this format are:

Model

WAIF describes web applications in terms of components and their properties. The principle component is the Service which represents a web application or service. A Service specifies the interactions that it supports along with a base URI that can be used to derive the URI for each interaction. An interaction deals with a specific type of resource and utilizes representations of that resource to manipulate it. An interaction may specify a path component to be combined with the service's base URI and also define a number of parameters that may be supplied as part of the URI query string. Parameters may be required or optional and may be grouped into sets which can also be required or optional. A parameter specifies a name to be used in the query string and can refer to a definition of its format and abstract purpose.

Service

A Service represents a web application or web service that makes resources available typically via HTTP.

The following properties are applicable to Service components:

WebInteraction

An WebInteraction component represents an operation or action that is supported by a Service.

The following properties are applicable to WebInteraction components:

ResourceType

A ResourceType represents the abstract type of HTTP resource that a WebInteraction is dealing with. Resource here refers to the RFC2616 concept of a network object or service that can be identified by a URI.

The ResourceType component has no special properties.

RepresentationType

A RepresentationType represents a type of representation that is understood by the Service and is supported in a particular Web Interaction. Representation here refers to the RFC2616 concept of a data representation of a resource.

For Interactions using the GET method, the RepresentationTypes listed will typically be alternate response formats that can be supplied by the WebInteraction and selected via standard HTTP practice. For POST based Interactions, the RepresentationTypes listed will be those accepted by the Web Interaction.

The following properties are applicable to RepresentationType components:

Parameter

A Parameter represents a query parameter used by a Web Interaction.

The following properties are applicable to Parameter components:

ParameterSet

A ParameterSet component represents a group of Parameter components. A Parameter can be a member of any number of ParameterSet components. Membership of a ParameterSet does not imply any form of relationship between Parameters.

The following properties are applicable to ParameterSet components:

Purpose

A Purpose component represents an abstract concept that is associated with a Parameter. Parameters that share the same Purpose can be inferred to be equivilent despite any syntactic differences.

The Purpose component has no special properties.

General Properties

The following properties may be used with any component:

Summary of Component Properties

Property Applies To Value Type Occurrence
homepage Service reference to web page 0 or 1
baseUri Service string 1
provides Service reference to WebInteraction any number
method WebInteraction string 1
label Any Component string any number
comments Any Component string any number
docs Any Component reference to web page any number
resourceType WebInteraction reference to ResourceType 0 or 1
representationType WebInteraction reference to RepresentationType any number
uriPath WebInteraction string 0 or 1
requiredParameter WebInteraction reference to Parameter any number
optionalParameter WebInteraction reference to Parameter any number
mediaType RepresentationType string 0 or 1
schemaType Parameter, RepresentationType reference 0 or 1
name Parameter string 1
purpose Parameter reference to Purpose any number
defaultValue Parameter string 0 or 1
fixedValue Parameter string 0 or 1
anyParametersFrom WebInteraction reference to ParameterSet any number
allParametersFrom WebInteraction reference to ParameterSet any number
oneParameterFrom WebInteraction reference to ParameterSet any number
allOrNoParametersFrom WebInteraction reference to ParameterSet any number
parameter ParameterSet reference to Parameter any number

XML Serialization

The XML serialization of WAIF (WAIF/XML) is a sane profile of RDF/XML strictly conforming to the XML Schema described later in this document. This simplifies processing by plain XML tools such as XPath and SAX by providing a deterministic document structure. Tools that store WAIF natively as RDF may utilize any RDF construct internally but must omit these when serializing as WAIF/XML. Other RDF-specific serialisation formats are possible and are not subject to the same processing constraints. However, all serializing WAIF tools that must support WAIF/XML output in order to provide interoperability.

No namespace URI has been assigned yet. All samples use http://example.com/wd# temporarily.

When accessed via HTTP, WAIF XML documents should be served with an application/rdf+xml media type. If unable to serve as application/rdf+xml, servers should use application/xml as an alternative. Servers must not use a media type of text/xml when serving WAIF XML.

Cross-Referencing Components

Components can be identified with a URI. The identifying URI must consist of the document location followed by a hash symbol (#), followed by an identifier name conforming to the XML NC-NAME production.

In the XML serialisation, RDF constructs are used only for cross-referencing WAIF components. The following attributes from the RDF namespace are used:

For example, in a document located at http://example.com/sample1.xml, the following Service component is described:

 
<wf:Service rdf:ID="foo">
  <wf:label>foo service</wf:label>
</wf:Service>

In this case the URI for the component would be http://example.com/sample1.xml#foo

Components and other resources such as web pages can be referred to using reference properties. The value of a reference property is a URI reference which can resolve to the component or web page.

In the XML serialization of WAIF, the reference is specified using the rdf:resource attribute on the property.

For example, in a document located at http://example.com/sample2.xml, the following WebInteraction component is described:

 
<wf:WebInteraction rdf:ID="action">
  <wf:label>an interaction</wf:label>
</wf:WebInteraction >

This WebInteraction component could be referred to within the same document using the rdf:resource attribute, e.g.

 
<wf:Service rdf:ID="foo">
  <wf:label>foo service</wf:label>
  <wf:supports rdf:resource="#action"/>
</wf:Service>

No other elements or attributes from the RDF namespace are allowed in the XML serialisation of WAIF documents.

Notes

These notes are areas that I want to expand upon in possible future versions but haven't had the time to evaluate properly yet.

Constructing Interaction URIs

To determine the URI for an Interaction:

  1. Take the baseURI of the Service being used
  2. Append the value of the Interaction's uriPath property, if any
  3. If the Interaction has parameters, append a question mark
  4. For each parameter append the parameter's name, an equals sign and the value to be used (all escaped as per URI rules)

Faults

This specification does not attempt to describe application-specific faults. Services utilizing the Web Architecture will respond to error conditions with standard HTTP response codes and these are well-described by the relevant specifications.

Comparison with WSDL

Existing web service description formats such as WSDL do not address the goals outlined at the start of this document. For comparison, in WSDL:

Examples

The following is a description of six API methods provided by del.icio.us

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF [
  <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">
]>
<rdf:RDF 
  xmlns:wf="http://example.com/wf#" 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://example.com/wf# http://iandavis.com/2005/web-description/waif.xsd">

  <wf:Service rdf:ID="DeliciousService">
    <wf:label>del.icio.us</wf:label>
    <wf:baseUri>http://del.icio.us/api/</wf:baseUri>
    <wf:homepage rdf:resource="http://del.icio.us/"/>
    <wf:provides rdf:resource="#Dates"/>
    <wf:provides rdf:resource="#Tags"/>
    <wf:provides rdf:resource="#Posts"/>
    <wf:provides rdf:resource="#RecentPosts"/>
    <wf:provides rdf:resource="#AllPosts"/>
    <wf:provides rdf:resource="#UpdateDate"/>
  </wf:Service>

  <wf:WebInteraction rdf:ID="Dates">
    <wf:comment xml:lang="en">returns a list of dates with the number of posts at each date.</wf:comment>
    <wf:docs rdf:resource="http://del.icio.us/doc/api"/>
    <wf:method>GET</wf:method>
    <wf:uriPath>posts/dates</wf:uriPath>
    <wf:resourceType rdf:resource="#DateList"/>
    <wf:representationType rdf:resource="#DateListXml"/>
    <wf:optionalParameter rdf:resource="#TagParameter"/>
  </wf:WebInteraction>

  <wf:WebInteraction rdf:ID="Tags">
    <wf:comment xml:lang="en">returns a list of tags the user has used.</wf:comment>
    <wf:docs rdf:resource="http://del.icio.us/doc/api"/>
    <wf:method>GET</wf:method>
    <wf:uriPath>tags/get</wf:uriPath>
    <wf:resourceType rdf:resource="#TagList"/>
    <wf:representationType rdf:resource="#TagListXml"/>
  </wf:WebInteraction>

  <wf:WebInteraction rdf:ID="Posts">
    <wf:comment xml:lang="en">
      returns a list of posts on a given date, filtered by tag. if no 
      date is supplied, most recent date will be used
    </wf:comment>
    <wf:docs rdf:resource="http://del.icio.us/doc/api"/>
    <wf:method>GET</wf:method>
    <wf:uriPath>posts/get</wf:uriPath>
    <wf:resourceType rdf:resource="#PostList"/>
    <wf:representationType rdf:resource="#PostListXml"/>
    <wf:optionalParameter rdf:resource="#TagParameter"/>
    <wf:optionalParameter rdf:resource="#DateParameter"/>
  </wf:WebInteraction>

  <wf:WebInteraction rdf:ID="RecentPosts">
    <wf:comment xml:lang="en">
      returns a list of most recent posts, possibly filtered by tag, maxes out at 100.
    </wf:comment>
    <wf:docs rdf:resource="http://del.icio.us/doc/api"/>
    <wf:method>GET</wf:method>
    <wf:uriPath>posts/recent</wf:uriPath>
    <wf:resourceType rdf:resource="#PostList"/>
    <wf:representationType rdf:resource="#PostListXml"/>
    <wf:optionalParameter rdf:resource="#TagParameter"/>
    <wf:optionalParameter rdf:resource="#CountParameter"/>
  </wf:WebInteraction>

  <wf:WebInteraction rdf:ID="AllPosts">
    <wf:comment xml:lang="en">
      returns all posts. use sparingly. call update function first
      to see if you need to fetch this at all
    </wf:comment>
    <wf:docs rdf:resource="http://del.icio.us/doc/api"/>
    <wf:method>GET</wf:method>
    <wf:uriPath>posts/all</wf:uriPath>
    <wf:resourceType rdf:resource="#PostList"/>
    <wf:representationType rdf:resource="#PostListXml"/>
    <!-- multiple representations allowed -->
    <wf:optionalParameter rdf:resource="#TagParameter"/>
  </wf:WebInteraction>

  <wf:WebInteraction rdf:ID="UpdateDate">
    <wf:comment xml:lang="en">
      returns the last update time for the user. combine this
      with posts/all to see if the data returned has changed
      since last fetch. this call is pretty lightweight. don't
      call posts/all unless you have to.
    </wf:comment>
    <wf:docs rdf:resource="http://del.icio.us/doc/api"/>
    <wf:method>GET</wf:method>
    <wf:uriPath>posts/update</wf:uriPath>
    <wf:resourceType rdf:resource="#Date"/>
    <wf:representationType rdf:resource="#DateXml"/>
  </wf:WebInteraction>

  <wf:ResourceType rdf:ID="DateList">
    <wf:comment xml:lang="en">A list of dates on which items have been tagged</wf:comment>
  </wf:ResourceType>

  <wf:ResourceType rdf:ID="TagList">
    <wf:comment xml:lang="en">A list of tags used by the user</wf:comment>
  </wf:ResourceType>

  <wf:ResourceType rdf:ID="PostList">
    <wf:comment xml:lang="en">A list of posts made by this user</wf:comment>
  </wf:ResourceType>

  <wf:ResourceType rdf:ID="Date">
    <wf:comment xml:lang="en">A date</wf:comment>
  </wf:ResourceType>

  <wf:RepresentationType rdf:ID="DateListXml">
    <wf:comment xml:lang="en">The response used for lists of dates</wf:comment>
    <wf:mediaType>application/xml</wf:mediaType>
  </wf:RepresentationType>

  <wf:RepresentationType rdf:ID="TagListXml">
    <wf:comment xml:lang="en">The response used for lists of tags</wf:comment>
    <wf:mediaType>application/xml</wf:mediaType>
  </wf:RepresentationType>

  <wf:RepresentationType rdf:ID="PostListXml">
    <wf:comment xml:lang="en">The response used for lists of posts</wf:comment>
    <wf:mediaType>application/xml</wf:mediaType>
  </wf:RepresentationType>

  <wf:RepresentationType rdf:ID="DateXml">
    <wf:comment xml:lang="en">The response used for item lookups</wf:comment>
    <wf:mediaType>application/xml</wf:mediaType>
  </wf:RepresentationType>

  <wf:Parameter rdf:ID="TagParameter">
    <wf:comment xml:lang="en">
        The name of a tag
    </wf:comment>
    <wf:name>tag</wf:name>
    <wf:schemaType rdf:resource="&xsd;string"/>
  </wf:Parameter>

  <wf:Parameter rdf:ID="DateParameter">
    <wf:comment xml:lang="en">
      A date to filter by
    </wf:comment>
    <wf:name>dt</wf:name>
    <wf:schemaType rdf:resource="&xsd;string"/><!-- ISO date -->
  </wf:Parameter>

  <wf:Parameter rdf:ID="CountParameter">
    <wf:comment xml:lang="en">
        number of items to retrieve
    </wf:comment>
    <wf:name>count</wf:name>
    <wf:schemaType rdf:resource="&xsd;positiveInteger"/>
  </wf:Parameter>

</rdf:RDF>

XML Schema

The schema is split into two parts: WAIF namespaced elements and a reduced RDF attributes schema for the two RDF attributes used in this specification.

RDF Schema

To follow...

Acknowledgements

I have drawn inspiration from the following specifications and proposals:

References

...incomplete...

RFC2616
IETF RFC 2616: Hypertext Transfer Protocol - HTTP/1.1, J. Gettys, J. Mogul, H. Frystyk, L. Masinter, P. Leach, T. Berners-Lee, June 1999, http://www.ietf.org/rfc/rfc2616.txt.
WEBARCH
Architecture of the World Wide Web, Volume One, I. Jacobs, N. Walsh , et. al., Editors, W3C Recommendation, 15 December 2004, http://www.w3.org/TR/2004/REC-webarch-20041215/.
XML10
Extensible Markup Language (XML) 1.0 (Third Edition), F. Yergeau, J. Paoli, C. M. Sperberg-McQueen, et. al., Editors, W3C Recommendation, 04 February 2004, http://www.w3.org/TR/2004/REC-xml-20040204
XMLNS
Namespaces in XML 1.1, R. Tobin, D. Hollander, A. Layman, et. al., Editors, W3C Recommendation, 04 February 2004, http://www.w3.org/TR/2004/REC-xml-names11-20040204.