The API targets the REST starter kit but is more broadly scoped, both on the client and on the server.  It enhances WCF offering but is not intended as a replacement of it.  Figure 1 depicts high level architecture of the concept, note that it still follows core WCF service model.

image

Figure 1 – Web API architecture

With Web API, REST has come ways to within striking distance of becoming a first class service model within the WCF platform.  It’s a set of libraries that enhance WCF’s REST offering, which may be downloaded directly at CodePlex or via NuGet (recommended).

To install the Web API package:

  1. Download and install NuGet
  2. Create new or open existing Visual Studio application
  3. Reference Web API package

image 

Figure 2 – NuGet context menu for project references

image

Figure 3 – NuGet reference management dialog

When a package is installed (e.g., referenced via NuGet) the following steps occur:

  1. A subfolder named packages is created at the solution root
  2. Libraries, with dependencies, are placed underneath it
  3. Project references, to the libraries in step 2, are made
  4. A configuration file, packages.config, is added to the project, identifying installed components

image

Figure 4 – WebApi.All component model

WebApi.All installs 4 components.  Full list of (Preview 4) components, libraries, namespaces, & classes are listed below:

  • HttpClient
    • Microsoft.Net.Http
      • System.Net.Http
        • ByteArrayContent
        • DelegatingChannel
        • FormUrlEncodedContent
        • HttpClient
        • HttpClientChannel
        • HttpCompletionOption
        • HttpContent
        • HttpException
        • HttpMessageChannel
        • HttpMethod
        • HttpRequestMessage
        • HttpResponseMessage
        • MessageProcessingChannel
        • MultipartContent
        • MultipartFormDataContent
        • StreamContent
        • StringContent
        • WebRequestChannel
      • System.Net.Http.Headers
        • AuthenticationHeaderValue
        • CacheControlHeaderValue
        • ContentRangeHeaderValue
        • EntityTagHeaderValue
        • HttpContentHeaders
        • HttpHeaders
        • HttpRequestHeaders
        • HttpResponseHeaders
        • MediaTypeHeaderValue
        • MediaTypeWithQualityHeaderValue
        • NameValueHeaderValue
        • NameValueWithParametersHeaderValue
        • ProductHeaderValue
        • ProductInfoHeaderValue
        • RangeConditionHeaderValue
        • RangeHeaderValue
        • RangeItemHeaderValue
        • RetryConditionHeaderValue
        • StringWithQualityHeaderValue
        • TransferCodingHeaderValue
        • TransferCodingWithQualityHeaderValue
        • ViaHeaderValue
        • WarningHeaderValue
  • JasonValue
    • Microsoft.Runtime.Serialization.Json
      • System.Json
        • JsonArray
        • JsonObject
        • JsonObjectValidation
        • JsonPrimitive
        • JsonType
        • JsonValue
        • JsonValueChange
        • JsonValueChangeEventArgs
        • JsonValueLinqExtensions
      • System.Runtime.Serialization.Json
        • JsonValueExtensions
    • Microsoft.ServiceModel.Web.jQuery
      • Microsoft.ServiceModel.Activation
        • WebServiceHostFactory3
      • Microsoft.ServiceModel.Configuration
        • WebHttpElement3
      • Microsoft.ServiceModel.Web
        • FormUrlEncodedExtensions
        • WebHttpBehavior3
        • WebServiceHost3

  • WebApi.Core (installs dependencies: HttpClient & JsonValue)
    • Microsoft.ApplicationServer.Common
      • Microsoft.ApplicationServer.Common
        • ChainedBeginHandler : MulticastDelegate
        • ChainedEndHandler : MulticastDelegate
      • Microsoft.ApplicationServer.Common.Notification
        • INotificationService
        • NotificationEvent
        • NotificationReceiver
        • NotificationSender
    • Microsoft.ApplicationServer.Http
      • Microsoft.ApplicationServer.Http
        • FormUrlEncodedMediaTypeFormatter
        • HttpBinding
        • HttpBindingSecurity
        • HttpBindingSecurityMode
        • HttpContentExtensionMethods
        • HttpRequestMessage<T>
        • HttpResponseMessage<T>
        • HttpServiceHost
        • IQueryComposer
        • JsonMediaTypeFormatter
        • JsonValueMediaTypeFormatter
        • MediaRangeMapping
        • MediaTypeFormatter
        • MediaTypeFormatterCollection
        • MediaTypeFormatterExtensionMethods
        • MediaTypeMapping
        • ObjectContent
        • ObjectContent<T>
        • QueryCompositionAttribute
        • QueryCompositionMessageProperty
        • QueryStringMapping
        • TrailingSlashMode
        • UriPathExtensionMapping
        • UrlQueryComposer
        • XmlMediaTypeFormatter
      • Microsoft.ApplicationServer.Http.Activation
        • HttpServiceHostFactory
      • Microsoft.ApplicationServer.Http.Channels
        • HttpMessageEncodingBindingElement
        • HttpMessageExtensionMethods
        • HttpMessageHandlerBindingElement
        • HttpMessageHandlerFactory
      • Microsoft.ApplicationServer.Http.Configuration
        • HttpBehaviorElement
        • HttpBindingCollectionElement
        • HttpBindingElement
        • HttpBindingSecurityElement
        • HttpEndpointCollectionElement
        • HttpEndpointElement
      • Microsoft.ApplicationServer.Http.Description
        • HttpBehavior
        • HttpEndpoint
        • HttpOperationDescription
        • HttpOperationDescriptionExtensionMethods
        • HttpOperationHandlerFactory
        • HttpParameter
        • HttpParameterExtensionMethods
      • Microsoft.ApplicationServer.Http.Dispatcher
        • HttpErrorHandler
        • HttpInstanceProvider
        • HttpMessageFormatter
        • HttpMessageInspector
        • HttpOperationHandler
        • HttpOperationHandler<T,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,TOutput>
        • HttpOperationHandler<T1,T2,T3,TOutput>
        • HttpOperationHandler<T1,T2,TOutput>
        • HttpOperationSelector
        • HttpResponseException
        • RequestContentHandler
        • ResponseContentHandler
        • UriAndMethodOperationSelector
        • UriTemplateHandler
    • Microsoft.ApplicationServer.Serialization
      • Microsoft.ApplicationServer.Serialization
        • IDataContractSurrogate
      • Microsoft.ApplicationServer.Serialization.Configuration
        • TypeElementExtensionMethods
    • Microsoft.ApplicationServer.ServiceModel
      • Microsoft.ApplicationServer.ServiceModel.Configuration
        • ServiceModelConfigurationElement
        • ServiceModelConfigurationElementCollection<ConfigurationElementType>
        • ServiceModelEnhancedConfigurationElementCollection<TConfigurationElement>
    • Microsoft.QueryComposition
      • Microsoft.QueryComposition.Client
        • ALinqExpressionVisitor
        • CountOption
        • DataServiceALinqExpressionVisitor
        • Evaluator
        • ExpressionNormalizer
        • InputReferenceExpression
        • ProjectionQueryOptionExpression
        • QueryOptionExpression
        • ReferenceEqualityComparer
        • ReferenceEqualityComparer<T>
        • ResourceBinder
        • ResourceExpression
        • ResourceSetExpression
        • UriWriter
      • Microsoft.QueryComposition.Server
        • DataServiceProviderMethods
        • OpenTypeMethods
        • QueryTranslator
    • WebApi.Enhancements (installs dependencies: Core)
    • Microsoft.ApplicationServer.HttpEnhancements
      • Microsoft.ApplicationServer.Http
        • HtmlForamtter
        • PlainTextFormatter
      • Microsoft.ApplicationServer.Http.Activation
        • HttpConfigurableServiceHost
        • HttpConfigurableServiceHost<TService>
        • HttpConfigurableServiceHostFactory
        • IConfigurableServiceHostFactory
        • RouteCollectionExtensions
      • Microsoft.ApplicationServer.Http.Description
        • HttpBehaviorWithErrorHandler
        • HttpErrorHandlerBehavior
        • HttpHostConfiguration
        • IContractConfiguration
        • IEndpointConfiguration
        • IEndpointFactory
        • IHttpHostConfigurationBuilder
        • InstanceProviderBehavior
        • IOperationConfiguration
        • IResourceFactory
        • IServiceConfiguration
        • ResourceFactoryProvider

To develop a Web API MVC service (source):

  1. Create empty MVC 3 app
  2. Reference WebApi
  3. Add DTO (POCO Data Transfer Object)
  4. Add & register service contract
  5. Add service operation
  6. Expose operation over http
  7. Consume operation (verification)