Introduction to RESTful services with WCF – Mobile Application Development, Web Services, SOA Architecture - Technology
Pular para o conteúdo

Introduction to RESTful Services with WCF – Mobile Application Development, Web Services, SOA Architecture

Adverts

First, RESTFUL services follow an architectural style known as Representational State Transfer (REST). An architectural style is a set of constraints that can be applied when building something. And a software architecture style is something that describes the characteristics that can be used to guide the implementation of a software system. REST is an architectural style that can be used to build software on which clients (user agents) can make requests for services (endpoints). REST is a way to implement a client/server style of architecture; in fact, REST is explicitly based on the client/server architectural style.

A man named Roy Thomas Fielding first coined the term REST as a concept in his doctoral dissertation (“Architecture Styles and the Design of Network-Based Software Architectures”). He was one of the people who worked on the specification that drives most of the Internet today: Hypertext Transfer Protocol (HTTP) Normally, the background of people describing an architectural style is not relevant to an explanation of the style, but here I THINK it is important because I BELIEVE that one of the best ways to gain a basic understanding of REST is to think about the web and how it works.

WCF and REST

WCF is Microsoft's framework for building applications that communicate over a network, regardless of protocol or style. The WCF concept was to create an extensible, pluggable framework for learning information about a programming and configuration model, so that developers could apply that knowledge to many different types of distributed systems.

While it's true that much of WCF is RPC-oriented (using SOAP), it has really had a chance to expose and consume REST services since it was first released as part of the .NET Framework 3.0. With the .NET Framework 3.5 assembly System.ServiceModel.Web was added a programming model as well as some pieces of infrastructure that were built to work with the REST style. And the .NET Framework 3.5 SP1 adds some small improvements to make REST easier to use..

The programming model revolves around two new attributes, WebGetAttribute and WebInvokeAttribute, and a URI template engine that allows you to declare the URI and verb that each method will respond to. The infrastructure is included in the form of a binding (WebHttpBinding) and a behavior (WebHttpBehavior) that provide the correct networking stack for using REST. In addition, there is some hosting infrastructure help from a custom ServiceHost (WebServiceHost) and a ServiceHostFactory (WebServiceHostFactory).