SlideShare a Scribd company logo
1 of 19
REST REpresentationalState Transfer
REST - Theory Resources  Representations Verbs Links Headers HTTP Status Codes
Resources A resource is identified by a Uri. Uri’s are considered Opaque. http://localhost/api/customers http://localhost/api/customers/1
Representations Fetching a resource returns a Representation. Representations have a content type i.e. text/xml, application/json, text/html etc. <customer>     <self>http://localhost/api.svc/customers/12</self>    <organisation>DevDefined</organisation>     <id>1</id>     <orders> http://localhost/api.svc/customers/12/orders     </orders> </customer>
Verbs ,[object Object]
GET must be Side Effect Free
PUT must be Idempotent.,[object Object]
Headers If-Modified-Since Etag Cache-Control Accept Content-Type Authorization
HTTP Status Codes (Just a few...)
Demos WCF – Building a Simple Rest Service Linq & REST – ADO.Net Data Services Entity Framework Custom classes MVC meets REST - MonoRail OAuth – RESTful Authorization
Demo #1 WCF Demo - A quick tour of a WCF REST service. webHttpBinding WebGetvsWebInvoke UriTemplates GET, POST, PUT, & Delete Changing the representation.
Fresh to Fiddler? 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. http://localhost.:8080/api.svc/customers/ FireFox users - you need to manually configure proxy settings.
WCF Gotchas 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.
Demo #2 ADO.Net Data Services (Was Astoria) Building Service using ADO.Net Entity Framework. Exploring Query Syntax.
Entity Framework 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(IDataServiceConfigurationconfig) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); }
Querying -Simple
Querying – Advanced
Custom Objects – Demo #3 ADO.Net Data Services isn’t limited to the EF. Anything implementing IQueryable interface will work too. Let’s try!
Implementation

More Related Content

What's hot

Overview of GraphQL & Clients
Overview of GraphQL & ClientsOverview of GraphQL & Clients
Overview of GraphQL & ClientsPokai Chang
 
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...Codemotion
 
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...Codemotion
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniternicdev
 
Learning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersLearning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersKathy Brown
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
Lecture17 ie321 dr_atifshahzad_js
Lecture17 ie321 dr_atifshahzad_jsLecture17 ie321 dr_atifshahzad_js
Lecture17 ie321 dr_atifshahzad_jsAtif Shahzad
 
A simple ReSTful webservice for the Goblins (v. 0.5)
A simple ReSTful webservice for the Goblins (v. 0.5)A simple ReSTful webservice for the Goblins (v. 0.5)
A simple ReSTful webservice for the Goblins (v. 0.5)Danilo Sanchi
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggetsguestbd1cdca
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsBG Java EE Course
 
OData and SharePoint
OData and SharePointOData and SharePoint
OData and SharePointSanjay Patel
 
Intro to the Intersection Observer API - Tara Ojo
Intro to the Intersection Observer API - Tara OjoIntro to the Intersection Observer API - Tara Ojo
Intro to the Intersection Observer API - Tara OjoFrontEnders
 
Gaining the Knowledge of the Open Data Protocol (OData) - Prairie Dev Con
Gaining the Knowledge of the Open Data Protocol (OData) - Prairie Dev ConGaining the Knowledge of the Open Data Protocol (OData) - Prairie Dev Con
Gaining the Knowledge of the Open Data Protocol (OData) - Prairie Dev ConWoodruff Solutions LLC
 
OData: A Standard API for Data Access
OData: A Standard API for Data AccessOData: A Standard API for Data Access
OData: A Standard API for Data AccessPat Patterson
 
Learning How to Shape and Configure an OData Service for High Performing Web ...
Learning How to Shape and Configure an OData Service for High Performing Web ...Learning How to Shape and Configure an OData Service for High Performing Web ...
Learning How to Shape and Configure an OData Service for High Performing Web ...Woodruff Solutions LLC
 

What's hot (20)

Overview of GraphQL & Clients
Overview of GraphQL & ClientsOverview of GraphQL & Clients
Overview of GraphQL & Clients
 
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
 
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
Michelle Garrett - Build the API you want to see in the world (with GraphQL) ...
 
REST for SQL Developers
REST for SQL DevelopersREST for SQL Developers
REST for SQL Developers
 
REST API Design for SQL developers
REST API Design for SQL developersREST API Design for SQL developers
REST API Design for SQL developers
 
A Look at OData
A Look at ODataA Look at OData
A Look at OData
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
 
Ofbiz Guy Gershoni 20060621
Ofbiz Guy Gershoni 20060621Ofbiz Guy Gershoni 20060621
Ofbiz Guy Gershoni 20060621
 
Learning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersLearning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client Developers
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
Lecture17 ie321 dr_atifshahzad_js
Lecture17 ie321 dr_atifshahzad_jsLecture17 ie321 dr_atifshahzad_js
Lecture17 ie321 dr_atifshahzad_js
 
A simple ReSTful webservice for the Goblins (v. 0.5)
A simple ReSTful webservice for the Goblins (v. 0.5)A simple ReSTful webservice for the Goblins (v. 0.5)
A simple ReSTful webservice for the Goblins (v. 0.5)
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggets
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
REST API for your WP7 App
REST API for your WP7 AppREST API for your WP7 App
REST API for your WP7 App
 
OData and SharePoint
OData and SharePointOData and SharePoint
OData and SharePoint
 
Intro to the Intersection Observer API - Tara Ojo
Intro to the Intersection Observer API - Tara OjoIntro to the Intersection Observer API - Tara Ojo
Intro to the Intersection Observer API - Tara Ojo
 
Gaining the Knowledge of the Open Data Protocol (OData) - Prairie Dev Con
Gaining the Knowledge of the Open Data Protocol (OData) - Prairie Dev ConGaining the Knowledge of the Open Data Protocol (OData) - Prairie Dev Con
Gaining the Knowledge of the Open Data Protocol (OData) - Prairie Dev Con
 
OData: A Standard API for Data Access
OData: A Standard API for Data AccessOData: A Standard API for Data Access
OData: A Standard API for Data Access
 
Learning How to Shape and Configure an OData Service for High Performing Web ...
Learning How to Shape and Configure an OData Service for High Performing Web ...Learning How to Shape and Configure an OData Service for High Performing Web ...
Learning How to Shape and Configure an OData Service for High Performing Web ...
 

Viewers also liked

Viewers also liked (6)

PublicECMeetingMay2015
PublicECMeetingMay2015PublicECMeetingMay2015
PublicECMeetingMay2015
 
Prova Xam2
Prova Xam2Prova Xam2
Prova Xam2
 
Taller Secundària 3 (Catalegs De Biblioteques I Revistes)
Taller Secundària 3 (Catalegs De Biblioteques I Revistes)Taller Secundària 3 (Catalegs De Biblioteques I Revistes)
Taller Secundària 3 (Catalegs De Biblioteques I Revistes)
 
Zcf+India +Revised
Zcf+India +RevisedZcf+India +Revised
Zcf+India +Revised
 
SRLA Studio Portfolio
SRLA Studio PortfolioSRLA Studio Portfolio
SRLA Studio Portfolio
 
OSC2009-do Lightning Talk
OSC2009-do Lightning TalkOSC2009-do Lightning Talk
OSC2009-do Lightning Talk
 

Similar to Ellerslie User Group - ReST Presentation

RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座Li Yi
 
Itemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integrationItemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integration{item:foo}
 
RestFull Webservices with JAX-RS
RestFull Webservices with JAX-RSRestFull Webservices with JAX-RS
RestFull Webservices with JAX-RSNeil Ghosh
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPStephan Schmidt
 
01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27Eoin Keary
 
Server-side Technologies in Java
Server-side Technologies in JavaServer-side Technologies in Java
Server-side Technologies in JavaAnirban Majumdar
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API DevelopmentAndrew Curioso
 
Introduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformIntroduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformAlfresco Software
 
REST - A Super Quick Intro
REST - A Super Quick IntroREST - A Super Quick Intro
REST - A Super Quick IntroSascha Wenninger
 
RESTful Services
RESTful ServicesRESTful Services
RESTful ServicesKurt Cagle
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsNeil Crookes
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Igor Moochnick
 

Similar to Ellerslie User Group - ReST Presentation (20)

Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
REST dojo Comet
REST dojo CometREST dojo Comet
REST dojo Comet
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
Itemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integrationItemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integration
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
RestFull Webservices with JAX-RS
RestFull Webservices with JAX-RSRestFull Webservices with JAX-RS
RestFull Webservices with JAX-RS
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHP
 
01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27
 
Server-side Technologies in Java
Server-side Technologies in JavaServer-side Technologies in Java
Server-side Technologies in Java
 
RIA and Ajax
RIA and AjaxRIA and Ajax
RIA and Ajax
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
 
Solr Presentation
Solr PresentationSolr Presentation
Solr Presentation
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
 
Introduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformIntroduction to Alfresco Surf Platform
Introduction to Alfresco Surf Platform
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
 
REST - A Super Quick Intro
REST - A Super Quick IntroREST - A Super Quick Intro
REST - A Super Quick Intro
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)
 

Recently uploaded

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

Ellerslie User Group - ReST Presentation

  • 2. REST - Theory Resources Representations Verbs Links Headers HTTP Status Codes
  • 3. Resources A resource is identified by a Uri. Uri’s are considered Opaque. http://localhost/api/customers http://localhost/api/customers/1
  • 4. Representations Fetching a resource returns a Representation. Representations have a content type i.e. text/xml, application/json, text/html etc. <customer> <self>http://localhost/api.svc/customers/12</self> <organisation>DevDefined</organisation> <id>1</id> <orders> http://localhost/api.svc/customers/12/orders </orders> </customer>
  • 5.
  • 6. GET must be Side Effect Free
  • 7.
  • 8. Headers If-Modified-Since Etag Cache-Control Accept Content-Type Authorization
  • 9. HTTP Status Codes (Just a few...)
  • 10. Demos WCF – Building a Simple Rest Service Linq & REST – ADO.Net Data Services Entity Framework Custom classes MVC meets REST - MonoRail OAuth – RESTful Authorization
  • 11. Demo #1 WCF Demo - A quick tour of a WCF REST service. webHttpBinding WebGetvsWebInvoke UriTemplates GET, POST, PUT, & Delete Changing the representation.
  • 12. Fresh to Fiddler? 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. http://localhost.:8080/api.svc/customers/ FireFox users - you need to manually configure proxy settings.
  • 13. WCF Gotchas 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.
  • 14. Demo #2 ADO.Net Data Services (Was Astoria) Building Service using ADO.Net Entity Framework. Exploring Query Syntax.
  • 15. Entity Framework 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(IDataServiceConfigurationconfig) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); }
  • 18. Custom Objects – Demo #3 ADO.Net Data Services isn’t limited to the EF. Anything implementing IQueryable interface will work too. Let’s try!
  • 20. ADO.Net Data Entities - Client 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).

Editor's Notes

  1. Uri’s are considered opaque – don’t try to pull them apart to infer additional meaning, you can only reliably rely on the representations returned from the GET’ing the uri and it’s associated metadata in headers to discover meaning about the resource.
  2. When you GET a resource you pull back a representation, it could be anything.Not all resources will provide enough fidelity to round-trip them.Representations should be strict out, loose in... This could mean using an XSD to validate output your service produces, but to be quite forgiving with what a client posts or puts back i.e. Using xpath to fetch only the elements you require, and to default missing elements to reasonable values.
  3. Unlike web services, which are effectively remote procedure calls, normally aligned with business processes – REST has a set of verbs, and each verb has a specific set of behaviour, working at a resource level.
  4. Add System.ServiceModel.Web reference.AddWebGet attributes.Add UriTemplate parameter to WebGet attribute.*Change wsHttpBinding to webHttpBindingExplain lack of “Self” or “Links” to related resources – need to be manually injected into DTO (Linq is good for this)
  5. Create service project.Remove default service, clean up the web.config.Select AdventureWorks.Select just tables.Add ADO.Net Data Service Item (under web tab, easier to find that way)Set the missing <T> parameter on DataService<T>... Set the access rules for entities and operations to be “free for all”.
  6. Show navigating to a workspaceDrill into Employee collectionDisplay first EmployeeDisplay contact details for first EmployeeDisplay gender property of employeeDisplay department history for a shift...
  7. Show navigating to a workspaceDrill into Employee collectionDisplay first EmployeeDisplay contact details for first EmployeeDisplay gender property of employeeDisplay department history for a shift...
  8. Add “SystemEntities” class exposing Queryable set of process DTO’s Process are returned by query via System.Diagnostics.Process.GetProcesses.Mention that we need to let ADO.Net data services know what the key is for out entity – and for that we need to reference another assembly: System.Data.Services.Client