Skip to content

WebServiceHost Overview

mikeobrien edited this page Sep 14, 2010 · 2 revisions

The WcfRestContrib.ServiceModel.Web.WebServiceHost offers a number of features to ease development of restful services.

  1. Ability to enable custom error handlers (See the Custom Error Handler Overview].
  2. Ability to set transfer mode.
  3. Ability to specify configuration behaviors (See the Declarative Binding & Behavior Overview).
  4. Ability to specify configuration bindings (See the Declarative Binding & Behavior Overview).

To use the WcfRestContrib.ServiceModel.Web.WebServiceHost simply change/add the service host factory in your service declaration to the WcfRestContrib.ServiceModel.Activation.WebServiceHostFactory as follows:

<%@ ServiceHost Language="C#" ... Service="NielsBohrLibrary.Books" 
    Factory="WcfRestContrib.ServiceModel.Activation.WebServiceHostFactory" %>

The WebServiceHost is configured with the WcfRestContrib.ServiceModel.Web.ServiceConfigurationAttribute. Apply this to the service and pass in your configuration. The following example demonstrates how to specify the custom error handler flag, transfer mode, binding configuration and behavior configuration:

[ServiceConfiguration(true, TransferMode.Streamed, "StreamedBinding", "RestBehavior")]
public class Content : IContentService {..}

Clone this wiki locally