Professional Documents
Culture Documents
Richard Blewett
richardb@develop.com
http://www.dotnetsonsult.co.uk/weblog2
SOAP == SOA?
2
SOAP != SOA?
3
REST = REpresentational State Transfer
GET http://www.acme.com/widgets/bypartno?partno=456
4
REST: Part of the Web
Customer
http://www2.acme.com/customer/smith123 DB N-Z
5
REST: Defining the Application Protocol
6
REST: URI is the State of the System
7
REST: Flexible Message Types
8
REST: Issues
• No metadata standard
– message “specifications” bespoke
– WADL in early stages
• No standard for “actions”
– format for next available operations bespoke
• Currently very little tool support
• Wedded to HTTP
– not formally but in practical terms
• Building a good REST API harder than first seems
– very easy to end up with RPC like API rather than relying on
URIs
9
SOAP and WCF
[ServiceContract]
interface IGetBooks
{
[OperationContract(Action="getbooks",
ReplyAction="getbooksResponse")]
Book[] GetBooks();
[OperationContract]
void AddBook(Book book);
}
10
REST and WCF
[ServiceContract]
interface IGetBooks
{
[OperationContract]
[WebGet(UriTemplate = "books/")]
Book[] GetBooks();
...
}
11
Data Dependent URIs
12
Binding Uri to Operation Parameters
[ServiceContract]
interface IGetBooks
{
[OperationContract]
[WebGet( UriTemplate= "books/{isbn}")]
Book GetBookByISBN(string isbn);
}
13
Enabling PUT and DELETE
[ServiceContract]
interface IGetBooks
{
[OperationContract]
[WebInvoke(Method="PUT", UriTemplate="books/")]
void AddBook(Book book);
}
14
Beyond the Plumbing
15
Status Codes
16
Content Types
17
Security
18
ASP.NET HTTP Pipeline Refresher
19
Implementing REST with ASP.NET
20
Mapping Handlers to URIs
r = new Route("books/isbn/{isbn}",
new BooksRouteHandler());
RouteTable.Routes.Add(r);
}
21
Processing the RouteTable
<system.web>
<httpModules>
<add name="Routing"
type="System.Web.Routing.UrlRoutingModule,
System.Web.Routing,
Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
22
Summary
23
Contact
Richard Blewett
Email: richardb@develop.com
Blog: http://www.dotnetconsult.co.uk/weblog2
24