Building RESTful application using SQL Azure, WCF, ADO.NET Data Service & Telerik OpenAccess WCF Wizard
- Telerik OpenAccess WCF Wizard: How-to Video #1
- Telerik OpenAccess WCF Wizard: How-to Video #2- Astoria
- Telerik OpenAccess WCF Wizard: How-to Video #3- REST Collections
- Telerik OpenAccess WCF Wizard: How-to Video #4- ATOMPub
- Using WCF for Silverlight Development with Telerik OpenAccess
- Using ADO.NET Data Services with Telerik OpenAccess’s WCF Wizard
- Using The WCF REST Starter Kit and REST Collections with Telerik OpenAccess’s WCF Wizard
- Using The WCF REST Starter Kit and ATOMPub with Telerik OpenAccess’s WCF Wizard
- Building a RESTful application with SQL Azure
WCF Essentials from MSDN
This section will serve as a summary of the steps you will take to design, implement, host and consume WCF services. The purpose is not to explain the details behind each design choice or feature – but to make you aware that these are things you should consider. Later sections of this whitepaper will provide recommendations to narrow the choices you face.
This section summarizes the available project templates, when to use each; and discusses the limitations and benefits of the core WCF tools.
A WCF RESTful service using ASP.NET MVC using REST MVC SDK
Hybrid choice that blends ASP.NET and WCF. The WCF team saw that many developers building ASP.NET MVC apps are more comfortable with the ASP.NET MVC programming model, but still want to supply more rich RESTful services from their web applications. So the WCF team put together an SDK and samples for building REST services using ASP.NET MVC.
You can download the samples and SDK from ASP.NET MVC 1.0 page on CodePlex.
Do read through the overview document as it describes the changes you’ll need to make to an application to make use of this framework. Also, the zip file includes several sample movie applications which demonstrate various scenarios and compares them to the baseline of not using the REST approach.
When to use ASP.NET MVC to build out REST-ful services and when to use WCF
A common question that comes up is when to use ASP.NET MVC to build out REST-ful services and when to use WCF?
when the only reason for the service’s existence is to service the one application you’re currently building, it may make more sense would stick with the simple case of using ASP.NET MVC. This is commonly the case when the only client to your JSON service is your web application’s Ajax code.
When your service is intended to serve multiple clients (not just your one application) or hit large scale usage, then moving to a real services layer such as WCF may be more appropriate.
WCF REST Starter Kit Preview 2
Preview 2 of the starter kit introduces a second set of client-side features for accessing WCF and third-party REST services from within .Net applications. The new HttpClient class provides the REST developer with a uniform extensible model for sending HTTP requests and processing HTTP responses, in a variety of formats. The new "Paste Xml as Type" Visual Studio add-in enhances the serialization support in HttpClient by generating serializable types based on XML examples or XSD schema.
Creating and consuming Rss/Atom syndication feed using WCF 3.5
The .NET Framework did not provide any built-in functionality for creating or consuming syndication feeds until version 3.5 with the introduction of the
System.ServiceModel.Syndicationnamespace. The most germane class in this namespace is SyndicationFeed. As you can probably guess from its name, this class represents a syndication feed. It has properties likeTitle,Description,Links, andCopyright, which provide details about the feed. The content items that make up the feed are specified via theItemsproperty, which is a collection of SyndicationItem objects. TheSyndicationFeedclass also has a staticLoadmethod that parses and loads the information from a specified RSS 2.0 or Atom 1.0 syndication feed.In addition to the
SyndicationFeedandSyndicationItemclasses, theSystem.ServiceModel.Syndicationnamespace also includes two formatter classes, Atom10FeedFormatter and Rss20FeedFormatter. These classes take aSyndicationFeedobject and generate the corresponding XML content that conforms to either the Atom 1.0 or RSS 2.0 specificiations.
What’s inside the WCF REST Starter Kit
- Visual Studio Project Templates
- REST Singleton Service produces a service that exposes the full HTTP interface (GET, POST, PUT, and DELETE) around a singleton resource, and it automatically provides both XML and JSON representations for the underlying resource.
- REST Collection Service similar to the REST Singleton Service only it also provides support for managing a collection of SampleItem resources.
- HTTP Plain XML Service provides ONLY the GET and POST operations for those who don’t care about fully conforming to the RESTful design and would rather build a REST/RPC hybrid service by overloading GET and POST using the HTTP Headers.
- Atom Feed Service template provides a sample implementation that shows how to programmatically generate and return a SyndicationFeed instance.
- Atom Publishing Protocol Service template produces a full-fledged AtomPub service capable of managing collections of resources as well as media entries.
- WebProtocolException allows you to directly set your HTTP status code.
- WebServiceHost2/WebServiceHost2Factory which provides a zero-config experience. Provide support for Help Page.
- Help Page and using [WebHelp] for annotation. Simply navigate to /help

- [WebCache]
- RequestInterceptor
- Added Extension methods to the WebOperationContext class.
You can download the WCF REST Starter Kit here.
For samples of using the starter kit, look at this A Developer Guide to the WCF REST Starter Kit.
A Tutorial on Building RESTful Web Services with WCF 3.5
- [WebGet], [WebInvoke] to define mappings for the Http Methods Interface
- UriTemplate to map objects to method signatures through WebGet/WebInvoke Attributes
- WebOperationContext to access the HTTP Request/Response including header and status code
- <%@ ServiceHost Factory=”WebServiceHostFactory” to auto-config the Web endpoints binding and behavior without edit web.config.
- aspNetCompatibilityEnabled(web.config) & AspNetCompatibilityRequirements(.cs) to access HttpContext
- (optional) using Microsoft URL Rewrite Module for IIS 7.0 to remove the .svc from the URIs.
- RequestFormat/ResponseFormat=WebMessageFormat.Xml/WebMessageFormat.Json through WebGet/WebInvoke Attributes.
- WebScriptServiceHost to auto-generate a Ajax-friendly JSON javascript proxy for web browsers. Append /js to the end of base address to get to the proxy.
- Use SyndicationFeed, SyndicationItem, SyndicationContent to build generic logical feeds.
- Use Atom10FeedFormatter, RSS20FeedFormatterClass to turn a SyndicationFeed object to Atom/RSS specific feed format. Method can use SyndicationFeedFormatter base class to return various formatter object.
- Use ServiceDocument, ServiceDocumentFormatter, AtomPub10ServiceDocumentFormatter, and Workspace to generate AtomPub service document. note: AtomPub as a standard application of the HTTP uniform interface(GET/PUT/POST/DELETE) but applied specifically to Atom feeds, which are modeled as collections of entries.
- Too tedious, try WCF REST Starter Kit. and you can download here.
Via A Guide to Designing and Building RESTful Web Services with WCF 3.5
Building OAuth channel for WCF RESTful services
What is OAuth?
While OpenID and WS-Federation focus on delegating user identity (or a collection of identity claims), OAuth was designed to address a different and complementary scenario, the delegation of user authorization. In few words, OAuth allows a client application to obtain user consent (i.e. Authorization for consuming a private resource as access tokens) for executing operations over private resources on his behalf.
If you want to know more about how OAuth works, you should read the following posts
OAuth .NET Library
Alex Henderson (Aka Bittercoder) has written a pretty good OAuth library in .NET for implementing an OAuth consumer and service provider. The library is available here under a MIT license (do wherever you want with it), and it is very easy to use. Alex has definitively made a very good work.
OAuth WCF Channel using REST Starter Kit’s RequestInterceptor
WCF channel implementation for OAuth mounts on top of his library and it basically transforms a OAuth token into a .NET security principal that can be used later within the service implementation. The channel is implemented as a RequestInterceptor, one of new features introduced in the REST WCF Starter Kit. This interceptor basically captures the request at channel level and performs all the validations required by OAuth. The following sample illustrates how the interceptors can be plugged into an existing service host (service.svc),
Samples here: OAuth channel for WCF RESTful services – Pablo M. Cibraro (aka Cibrax)
Windows Communication Foundation (WCF) 3.5 REST Starter Kit
Windows Communication Foundation (WCF) REST Starter Kit
The WCF REST Starter Kit is a set of features, Visual Studio templates, samples and guidance that enable users to create REST style services using WCF. It provides features that enable or simplify various aspects of using the http capabilities in WCF, such as caching, security, error handling, help page support, conditional PUT, push style streaming, type based dispatch and semi-structured XML support. The WCF REST Starter Kit also provides Visual Studio templates for creating REST style services such as an Atom feed service, a REST-RPC hybrid service, Resource singleton and collection services and an Atom Publishing Protocol service. In addition, there are samples, documentation and other guidance that help to use these new capabilities.
Download WCF REST Starter Kit – Download
Learn about WCF REST Starter Kit
- Overview
- Screencasts
- endpoint.tv Screencast – Getting Started with the WCF REST Starter Kit
- endpoint.tv Screencast – Building REST collection services with the WCF REST Starter Kit
- endpoint.tv Screencast – Building REST singleton services with the WCF REST Starter Kit
- endpoint.tv Screencast – A lap around the new API extensions for REST – Part 1
- endpoint.tv Screencast – A lap around the new API extensions for REST – Part 2
- endpoint.tv Screencast – Building AtomPub services with the WCF REST Starter Kit
- endpoint.tv Screencast – Building Atom feeds with the WCF REST Starter Kit
MUST READ – A Guide to Designing and Building RESTful Web Services with WCF 3.5
- Hands-on Labs
In the case of REST Singleton Web Service, using jQuery to do AJAX is as simple as:
<script type=”text/javascript”>
$(function() {
$.getJSON(“http://localhost:62537/Service.svc/?format=json”, null, function(json) {
$(‘#result’).html(json.Value);});
})
</script>
