MindTouch Dream: REST SDK & Lightweight Standalone Server

MindTouch offers a programming library and standalone server for developing and publishing RESTful web services. Dream "Denim" 1.4.1 has been released last week.

MindTouch Dream is on Open Source Project covered by the Gnu Lesser General Public License Agreement (LGPL). It is written in C# entirely and runs on Microsoft .NET 2.0 as well as Novell Mono 1.2.5. According to Steve Bjorg, co-founder of MindTouch, "the best way to describe it is in guise of a question: 'What would a web-centric programming environment look like if it were built from ground up for a service-oriented world?'”:

There are several key features that set Dream apart from other frameworks for .Net, such as Windows Communication Foundation:

it’s lightweight

it’s cross-platform

it’s built to comply with industry standards

it’s open source

and it’s devoid of SOAPiness!

The key concept of Dream is the web service. A web service gets instantiated by the runtime and provides entry points, called "features". Features are invoked by issuing an HTTP request, consisting of the Dream Host base address extended by the service name and a URI pattern as well as an HTTP verb such as GET, PUT, POST, DELETE. A feature is mapped to a CLR method by a Dream Attribute, which defines the verb and the URI pattern:

The first parameter of the DreamFeature Attribute defines the verb and the pattern, separated by a colon. Dream services and consumers exchange data in form of XML or binary streams. Normally Dream services expect and deliver XML documents. These documents are wrapped by DreamMessage instances.

The Dream SDK provides an easy to use XDoc class, which wraps the .NET XML classes, in order to alleviate the use and creation of XML documents:

XDoc is the Swiss army knife for all things XML. It is a lightweight wrapper around the XmlDocument, XmlElement, XmlText, and XmlNodeList classes, making it easy to create, query, and compose XML documents. With XDoc, you don't have to know any of the .Net XML classes because all operations result in new XDoc instances, which keeps everything really simple!

Dream provides a set of generic features, available to all services and a core service library "that address common problems when writing any kind of interesting web-services or web-applications".

Dream services can be hosted in a console host application or a custom environment, e.g. NT Service. The console host application provides a command line interface to create a new Dream hosting environment. The Dream hosting environment is implemented by the Dream Host. The runtime might also be hosted within IIS6. Requests will be handled by the included Dream HTTPHandler. The Dream runtime

is responsible for orchestrating all interactions. It is built using the HttpListener class and thus requires no web-server to be pre-installed on the target device. It is responsible for instantiating services, routing messages to them, and short-circuiting service-to-service communication when both are co-located (meaning they are loaded inside the same AppDomain).

Plugs are a convenience feature that allow to switch from HTTP communication to in-memory communication when services are co-located inside the same AppDomain:

Plugs greatly simplifies talking to web resources. Besides replacing WebRequest, plugs also detect when a service is co-located (i.e. hosted inside the same AppDomain). In that case, instead of using expensive serialization/deserialization operations, plugs use direct in-memory communication. Plugs also make it easy to adjust the URI of the target service to specify the desired feature or processing options.