REpresentational State Transfer.  Resources  Representations  Verbs  Links  Headers  HTTP Status Codes.

Slides:



Advertisements
Similar presentations
REST &.NET James Crisp.NET Practice Lead ThoughtWorks Australia.
Advertisements

OASIS OData Technical Committee. AGENDA Introduction OASIS OData Technical Committee OData Overview Work of the Technical Committee Q&A.
Background REST (Representational State Transfer) What does it mean to be RESTful? Why REST? WCF How does WCF support REST? What are the pieces we need.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
ASP.NET Best Practices Dawit Wubshet Park University.
.NET Framework V3.5+ & RESTful web services Mike Taulty Developer & Platform Group Microsoft Ltd
Microsoft ® Official Course Interacting with the Search Service Microsoft SharePoint 2013 SharePoint Practice.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Jon Flanders INT303. About Me  Jon Flanders –  Independent consultant/trainer  BizTalk MVP.
PL-IV- Group A HTTP Request & Response Header
Service Broker Lesson 11. Skills Matrix Service Broker Service Broker, provides a solution to common problems with message delivery and consistency that.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
OAuth-as-a-service using ASP.NET Web API and Windows Azure Access Control Maarten
Building Data Driven Applications Using WinRT and XAML Sergey Barskiy, Magenic Microsoft MVP – Data Platform Principal Consultant Level: Intermediate.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
Databases and LINQ Visual Basic 2010 How to Program 1.
CPSC 203 Introduction to Computers T59 & T64 By Jie (Jeff) Gao.
Initial Data Load Extension Module Webinar February 4th, 2009.
FTP (File Transfer Protocol) & Telnet
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
Designing and Implementing Web Data Services in Perl
Tutorial 1 Getting Started with Adobe Dreamweaver CS3
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Marc Ziss Z Consulting Code Name 'Oryx' Web application scaffolding Easy to dynamically display pages based on the data model of.
Sustainable SharePoint 2010 Customizations By Bill Keys.
ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK
Service Interfaces Atom & AtomPub Atom-Enabled Data Services Drill Down: Windows Live Spaces Photos Data Services Framework Wrap-up.
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
Open Data Protocol * Han Wang 11/30/2012 *
Project “Astoria” first announced in Mix 2007 Shared early prototypes, got tons of feedback Now we’re talking about the real deal Production quality bits,
Introduction to Entity Framework Part 2 CRUD Scaffolding Tom Perkins NTPCUG.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
Lap Around Visual Studio 2008 &.NET 3.5 Enhancements.
11 Using ADO.NET II Textbook Chapter Getting Started Last class we started a simple example of using ADO.NET operations to access the Addresses.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
Introduction to the SharePoint 2013 REST API. 2 About Me SharePoint Solutions Architect at Sparkhound in Baton Rouge
Web Service Programming with WCF 3.5 Eyal Vardi CEO E4D Solutions LTD Microsoft MVP Visual C# blog:
SNOWTAM Trial: REST Interface. AIXM XML Developers' Seminar 2 Contents Digital-SNOWTAM Trial Introduction REST Introduction REST in the Digital-SNOWTAM.
A FIRST TOUCH ON NOSQL SERVERS: COUCHDB GENOVEVA VARGAS SOLAR, JAVIER ESPINOSA CNRS, LIG-LAFMIA, FRANCE
API Crash Course CWU Startup Club. OUTLINE What is an API? Why are API’s useful? What is HTTP? JSON? XML? What is a RESTful API? How do we consume an.
Building a Web API for browser/JSON clients.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
1 ADO.NET Data Services Mike Taulty Developer & Platform Group Microsoft Ltd
1 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 2: REST Details and Patterns Some.
IST 220 – Intro to Databases Lecture 2 Touring Microsoft Access.
RESTful Web Services What is RESTful?
Web Technologies Lecture 11 Implementing RESTful services.
CPSC 203 Introduction to Computers T97 By Jie (Jeff) Gao.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
2 ADO.NET Data Services for the Web Mike Flasko Program Manager, Microsoft “Project Astoria”
Intro to REST Joe Gregorio Google. REST is an Architectural Style.
Jim Fawcett CSE686 – Internet Programming Spring 2014
Building and Consuming REST-based Data Services for the Web
Introduction to .NET Florin Olariu
IST 220 – Intro to Databases
Data Virtualization Tutorial… CORS and CIS
Contents Digital-SNOWTAM Trial Introduction REST Introduction
CO6025 Advanced Programming
Entity Framework 4 and WCF Data Services 4
WEB API.
Accessing Data in a .NET Web Application
Relational Database Design
Requests and Server Response Codes
Visual Studio + SQL Server Is Better
WCF Data Services and Silverlight
.NET Framework V3.5+ & RESTful web services
Presentation transcript:

REpresentational State Transfer

 Resources  Representations  Verbs  Links  Headers  HTTP Status Codes

 A resource is identified by a Uri.  Uri’s are considered Opaque.

 Fetching a resource returns a Representation.  Representations have a content type i.e. text/xml, application/json, text/html etc. DevDefined 1

ConceptualSQLHTTP (REST) FindSELECTGET CreateINSERTPOST... Or PUT UpdateUPDATEPUT DestroyDELETE  HTTP Verbs are used to operate on resources.  GET must be Side Effect Free  PUT must be Idempotent.

 Links are returned in representations.  Clients follow links, allowing them to transition state.  Using Links can provide elegant ways to scale out or integrate 3 rd party services.

 If-Modified-Since  Etag  Cache-Control  Accept  Content-Type  Authorization

CodeNameDescription 200OKSuccessful Request. 201CreatedNew resource created, returns Uri. 202AcceptedRequest accepted, but resources haven’t been created yet. 304Not ModifiedConditional get, resource is unchanged (so we can use a previously cached resource) 400Bad RequestError in request(i.e. request failed validation) 404Not FoundResource was not found. 405Method Not Allowed i.e. If you try to delete a read-only resource, or the whole resource container. 500Internal Server ErrorSomething else went wrong (default status for errors in WCF).

 WCF – Building a Simple Rest Service  Linq & REST – ADO.Net Data Services ▪ Entity Framework ▪ Custom classes  MVC meets REST - MonoRail  OAuth – RESTful Authorization

 WCF Demo - A quick tour of a WCF REST service.  webHttpBinding  WebGet vs WebInvoke  UriTemplates  GET, POST, PUT, & Delete  Changing the representation.

 Fiddler is very useful when developing REST services.  There are some catches for first time users:  Disable IPV6 in Fiddler when using Cassini (it doesn’t like the ::1 loopback address)  Use “.” after localhost when testing with IE 7 to stop proxy being bypassed. ▪ i.e.  FireFox users - you need to manually configure proxy settings.

 Exceptions end up as 500 errors on client. ▪ You need to explicitly set status for non-server errors (i.e. For invalid requests)  Uri Templates are fussy ▪ Trailing slashes will cause a match to fail, contrary to many peoples expectations.  HTTP Method names are case-sensitive. ▪ Using “Post” instead of “POST” can make for confusing 405 errors  The input/output Representation format is defined at the contract operation level. ▪ Targeting multiple representations “across the board” is ugly.  Support for linking resources is non-existent.

 ADO.Net Data Services (Was Astoria)  Building Service using ADO.Net Entity Framework.  Exploring Query Syntax.

 Using EF - Out of scope  However... Provides easy way to quickly play with Astoria.  Add Item -> Entity Model  Use AdventureWorks database, just the tables should do, call it “AdventureWorks”  Add Item -> ADO.Net Data Service  Edit the.cs file, set entities class for service to AdventureWorksModel.AdventureWorksEntities.  Alter InitializeService method to look like this (Don’t do this for production use) public static void InitializeService(IDataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); } public static void InitializeService(IDataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); }

UriConceptual /List of types / tables - “Workspace” in AtomPub. /EmployeeList of instances / rows - “Collection” or “Feed’ in AtomPub. /Employee(1)Instance / Row by Key(s) – Collection “Member” or “Entry” in AtomPub /Employee(1)/ContactForeign Key / Relationship /Employee(1)/GenderProperty / Column /ProductProductPhoto(ProductID=332,ProductP hotoID=160) Instance (Composite Key) /Product?$orderby=NameOrder the results by the Name property. /Product?$orderby=ListPrice desc, NameOrder by ListPrice in descending Order, then Name ascending.

UriConceptual /Product?$filter=contains(Name,'wheel')All products matching filter:.Select(p=>p.Name.Contains(“wheel’)) /Shift(1)/EmployeeDepartmentHistory?$ filter=EmployeeID eq 30 Navigated Relationship with clause, same as: Shifs.Select(s => s.Id == 1).SelectMany(s => s.EmployeeDepartmentHistory).Where(history => history.EmployeeID == 30) /Product(528)?$expand=BillOfMaterialsWill expand the Navigation Property in-line instead of linking to it. /Product?$top=20Top 20 results, same as:.Take(20) /Product?$skip=20&$take=10Display page 3 (with page size of 10) same as:.Skip(20).Take(10)

 ADO.Net Data Services isn’t limited to the EF.  Anything implementing IQueryable interface will work too.  Let’s try!

 Entities comes with a.Net Client. ▪ Found in the System.Data.Services.Client assembly.  Client allows Linq -> Uri -> Linq -> Whatever. ▪ With different Types on the client and Server! ▪ Client types can be POCO objects, even if the server side representations are not. ▪ [DataServiceKey(...)] attribute required to support non-GET requests.  Client implements a “unit of work” like pattern, allowing changes to be collected and then persisted at once.  Changes can be batched in a single request (though this can be viewed as a perversion of HTTP principles).