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.
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:
- Download and install NuGet
- Create new or open existing Visual Studio application
- Reference Web API package
Figure 2 – NuGet context menu for project references
Figure 3 – NuGet reference management dialog
When a package is installed (e.g., referenced via NuGet) the following steps occur:
- A subfolder named packages is created at the solution root
- Libraries, with dependencies, are placed underneath it
- Project references, to the libraries in step 2, are made
- A configuration file, packages.config, is added to the project, identifying installed components
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
- System.Net.Http
- Microsoft.Net.Http
- JasonValue
- Microsoft.Runtime.Serialization.Json
- System.Json
- JsonArray
- JsonObject
- JsonObjectValidation
- JsonPrimitive
- JsonType
- JsonValue
- JsonValueChange
- JsonValueChangeEventArgs
- JsonValueLinqExtensions
- System.Runtime.Serialization.Json
- JsonValueExtensions
- System.Json
- Microsoft.ServiceModel.Web.jQuery
- Microsoft.ServiceModel.Activation
- WebServiceHostFactory3
- Microsoft.ServiceModel.Configuration
- WebHttpElement3
- Microsoft.ServiceModel.Web
- FormUrlEncodedExtensions
- WebHttpBehavior3
- WebServiceHost3
- Microsoft.ServiceModel.Activation
- Microsoft.Runtime.Serialization.Json
- 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.Common
- 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.Http
- Microsoft.ApplicationServer.Serialization
- Microsoft.ApplicationServer.Serialization
- IDataContractSurrogate
- Microsoft.ApplicationServer.Serialization.Configuration
- TypeElementExtensionMethods
- Microsoft.ApplicationServer.Serialization
- Microsoft.ApplicationServer.ServiceModel
- Microsoft.ApplicationServer.ServiceModel.Configuration
- ServiceModelConfigurationElement
- ServiceModelConfigurationElementCollection<ConfigurationElementType>
- ServiceModelEnhancedConfigurationElementCollection<TConfigurationElement>
- Microsoft.ApplicationServer.ServiceModel.Configuration
- 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
- Microsoft.QueryComposition.Client
- 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
- Microsoft.ApplicationServer.Http
- Microsoft.ApplicationServer.Common
To develop a Web API MVC service (source):
- Create empty MVC 3 app
- Reference WebApi
- Add DTO (POCO Data Transfer Object)
- Add & register service contract
- Add service operation
- Expose operation over http
- Consume operation (verification)
brettedotnet said:
Nice post.