session objectives and takeaways

36
Implementing RESTful Services With WCF 3.5 SP1 Security, Scalability and Controlling the URI (Part 2 of 2)

Upload: dallon

Post on 11-Feb-2016

87 views

Category:

Documents


0 download

DESCRIPTION

Implementing RESTful Services With WCF 3.5 SP1 Security , Scalability and Controlling the URI (Part 2 of 2). Session Objectives And Takeaways. Go a level deeper than we did in Part 1 Describe how optional HTTP features like caching and conditional GET impact scalability - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Session Objectives And Takeaways

Implementing RESTful Services With WCF 3.5 SP1Security, Scalability and Controlling the URI (Part 2 of 2)

Page 2: Session Objectives And Takeaways

Session Objectives And Takeaways

Go a level deeper than we did in Part 1Describe how optional HTTP features like caching and conditional GET impact scalabilityExplain how you can fully control the URIConsider options for securing RESTful servicesLearn about the updates to WCF in 3.5 SP1

Page 3: Session Objectives And Takeaways

Agenda

What is REST and Why should I care?How will resources be addressed?How will resources be formatted?How do I insure scalability?How do I secure my service?

Page 4: Session Objectives And Takeaways

SOAP RESTWCF Test Client Notepad

Internet Explorer

Why REST?

REST is an architectural style for implementing services with the simple and open model of the webSOAP is a protocol that delivers a rich messaging model independent of the transport

5 HTTP Messages18,604 bytes“You entered: 1”

Page 5: Session Objectives And Takeaways

Agenda

What is REST and Why should I care?How will resources be addressed?How will resources be formatted?How do I insure scalability?How do I secure my service?

Page 6: Session Objectives And Takeaways

Information ArchitectureURI Verb Collection Action

/wine POST Wine Create

/wine/{wineId} GET Wine Read

/wine/{wineId} PUT Customers Update

/wine/{wineId} DELETE Customers Delete

/wine/series/{seriesId} GET Wine Series Read

/wine/{wineId}/reviews GET Wine Reviews Read

/wine/{wineId}/reviews POST Wine Reviews Create

Page 7: Session Objectives And Takeaways

Default WCF Web URI

http://localhost/service.svc/method?arg1=1

Authority

.svc File path Method

nameQuery

Arguments

Scheme

Page 8: Session Objectives And Takeaways

WCF 3.5 UriTemplates

UriTemplate allows you to override the defaultArguments are bound by name

[OperationContract][WebGet(UriTemplate="Wine/{wineId})]WineData GetWine(string wineId);

http://localhost/service.svc/Wine/1

Page 9: Session Objectives And Takeaways

New in WCF 3.5 SP1

Default Values for template items Cannot be used for query string values

[OperationContract][WebGet(UriTemplate="Wine/{wineID=17})]WineData GetWine(string wineID);

Page 10: Session Objectives And Takeaways

New in WCF 3.5 SP1

Compound Template Segments

[OperationContract][WebGet(UriTemplate=“wine({wineID})]WineData GetWine(string wineID);

http://localhost/service.svc/wine(17)

Page 12: Session Objectives And Takeaways

DemoControlling the URI

Page 13: Session Objectives And Takeaways

Agenda

What is REST and Why should I care?How will resources be addressed?How will resources be formatted?How do I insure scalability?How do I secure my service?

Page 14: Session Objectives And Takeaways

Message Schema

Option 1: Basic Atom FeedStandardized syndication schemaWCF 3.5 SP1 Supports All Atom Publishing Protocol types

Option 2: Custom Service SchemaYou create your own schema for messages using DataContracts or XSDSee Part 1 session for examples

Page 15: Session Objectives And Takeaways

microformats

Standards for common human readable data in (X)HTMLhCard, hCalendar, etc.

<div id="" class="vcard"> <a class="url fn n" href="http://www.cohowinery.net"> <div class="org">Coho Winery</div></a><a class="email" href="mailto:[email protected]">[email protected]</a> <div class="adr"> <div class="street-address">555 Wine Lane</div> <span class="locality">Napa</span> <span class="region">CA</span> <span class="postal-code">94558</span> <span class="country-name">USA</span></div> <div class="tel">800-555-1212</div></div>

Page 16: Session Objectives And Takeaways

DemoBasic Atom Feed

Page 17: Session Objectives And Takeaways

Content Negotiation

Allow the client to ask for the format they wantAccept HeaderExtension Query String

Fixed Content FormatAttribute your WCF service

Page 18: Session Objectives And Takeaways

DemoContent Negotiation

Page 19: Session Objectives And Takeaways

Agenda

What is REST and Why should I care?How will resources be addressed?How will resources be formatted?How do I insure scalability?How do I secure my service?

Page 20: Session Objectives And Takeaways

Caching

Client SideControlled by HTTP HeadersCache-Control

Instructions to client side cacheExpires

Server SideHttpRuntime.Cache“Velocity” Distributed Cache

CTP1 Now Available

Page 21: Session Objectives And Takeaways

Conditional Get

GET this data if...If-Modified-Since: (Date)

Return the data only if it has been modified since (Date)

If-None-Match: (Etag)Return the data only if there isn't one with this Etag

Saves Bandwidth by not transmitting old dataResponse.SuppressEntityBody

Page 22: Session Objectives And Takeaways

DemoCaching / Conditional Get

Page 23: Session Objectives And Takeaways

Agenda

What is REST and Why should I care?How will resources be addressed?How will resources be formatted?How do I insure scalability?How do I secure my service?

Page 24: Session Objectives And Takeaways

Security Scenarios

Developer / App AuthorizationAuthorizes an application to access RESTful services

Third Party AccessApplication or site accessing a protected resource on behalf of another

Human RIA UserAccessing a protected resource from an Ajax or Silverlight web page using a cookie

Page 25: Session Objectives And Takeaways

Developer / App Authorization

Control access to public servicesAllows you to revoke access if necessary

Developer is issued a token or application ID (or both)Verify email and acceptance of licenseEach request requires the token to be sent

URI may also include a signature to prevent request tamperingTokens may be sent in the URI or Authorization header

Page 26: Session Objectives And Takeaways

OAuth (Open Authentication)

An open protocol to allow secure API authentication in a simple and standard method from desktop and web applications.

OAuth.netAllows users to grant access to protected resources without having to give credentials to third partiesMySpace WCF Implementation

RestChess.com

Page 27: Session Objectives And Takeaways

Human RIA User

AuthenticationAjax authentication service is enabledHuman signs in to web site with script that calls Sys.Services.AuthenticationService.LoginAuthorization token returned in cookieClient side script accesses protected resources using cookie

AuthorizationServer authorizes client requests by placing a web.config file in the folder with the resource

Page 28: Session Objectives And Takeaways

DemoHuman RIA Security

Page 29: Session Objectives And Takeaways

Summary

RESTful Services work the way the Web worksSharing your data with the world works

Focus on simple and open ideas firstChoose broad adoption over elegant design

Embrace the protocol of the web HTTPUnderstand its semanticsUse it as designed

Page 30: Session Objectives And Takeaways
Page 31: Session Objectives And Takeaways

appendix

Page 32: Session Objectives And Takeaways

WCF Test Client

Page 33: Session Objectives And Takeaways

Fiddler Proxy

Page 34: Session Objectives And Takeaways

Yahoo Web Search Service back

Page 35: Session Objectives And Takeaways

Notepad Service Client?

Page 36: Session Objectives And Takeaways

Adventure Works Customer Get