Implementing RESTful Services With Windows Communication Foundation 3.5 SP1 - PowerPoint PPT Presentation

Implementing restful services with windows communication foundation 3 5 sp1
Download
1 / 22

  • 89 Views
  • Uploaded on
  • Presentation posted in: General

Implementing RESTful Services With Windows Communication Foundation 3.5 SP1. Concepts and Introduction(Part 1 of 2). Session Objectives. Provide you with an overview of REST Understand the REST support of WCF 3.5 Learn how to build an AJAX-Friendly service

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Download Presentation

Implementing RESTful Services With Windows Communication Foundation 3.5 SP1

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Implementing restful services with windows communication foundation 3 5 sp1

Implementing RESTful Services With Windows Communication Foundation 3.5 SP1

  • Concepts and Introduction(Part 1 of 2)


Session objectives

Session Objectives

  • Provide you with an overview of REST

  • Understand the REST support of WCF 3.5

  • Learn how to build an AJAX-Friendly service

  • Learn how to build a HI-REST service

  • Get you fired up with Demos


Agenda

Agenda

  • Why The Web Works

  • What is REST?

  • How REST works in WCF 3.5

  • LO-REST Demo (AJAX)

  • HI-REST Demo (AJAX & Silverlight 2.0)


Why the web works

Why The Web Works

  • Simple & Open

    • Addressing scheme – URI

    • Application protocol – HTTP

    • Representation Format - (X)HTML

    • Response Codes – HTTP Status

  • Scales Best When

    • Stateless

    • Cached

  • It works because people find value in it


How do we move from a web of pages to a web of services

How do we move from a web of pages to a web of services?

Circa 1998


Soap web services

SOAP Web Services

  • HTTP POST of an XML Message (SOAP Envelope)

  • WSDL describes SOAP service

  • WS-* provides extended functionality

  • Standardized and interoperable

  • <s:Envelope>

  • <s:Header>

  • <Action s:mustUnderstand="1">

  • http://t.org/IService1/GetData

  • </Action>

  • </s:Header>

  • <s:Body>

  • <GetData>

  • <value>1</value>

  • </GetData>

  • </s:Body>

  • </s:Envelope>


Wcf 3 0 soap http bindings

WCF 3.0 SOAP/HTTP Bindings

  • basicHttpBinding

    • Conforms to WS-I Basic Profile 1.1 standards

    • Compatibile with ASP.NET Web Services (asmx)

  • wsHttpBinding

    • A composable protocol stack allowing standards based additions

      • WS-Security


Agenda1

Agenda

  • Why The Web Works

  • What is REST?

  • How REST works in WCF 3.5

  • LO-REST Demo (AJAX)

  • HI-REST Demo (AJAX & Silverlight 2.0)


Restful tenents

RESTfulTenents

  • The Web of Services should work the way the Web of Pages works.

  • Simple & Open

  • The Universal API - HTTP

  • Linked Resources

  • Services Scale Best When

    • Stateless

    • Cached

      • Built into the HTTP protocol when leveraged properly


Rest continuum

REST Continuum

  • Well Constructed URIs

  • HTTP Verbs

    • GET – Fetch

    • PUT – Update / Insert

    • DELETE – Delete

    • POST – Append

  • Standard Representations

Hi-REST

Lo-REST

RESTfullness

Purists

Pragmatists

  • POST to 1 URI OK

  • Querystrings OK

  • HTTP Verbs

    • GET – Fetch

    • POST - Overloaded

  • AJAX Services

  • POX OK


The microsoft position

The Microsoft Position

  • SOAP is great

  • REST is great

  • Use WCF to build either one and go in peace


Agenda2

Agenda

  • Why The Web Works

  • What is REST?

  • How REST works in WCF 3.5

  • LO-REST Demo (AJAX)

  • HI-REST Demo (AJAX & Silverlight 2.0)


Webhttpbinding

webHttpBinding

  • New “web-friendly” WCF Binding in Fx 3.5

    • Allows for the development of RESTful services

    • Does not use SOAP envelopes

    • HTTP and HTTPS Transports Only

  • Works across REST Continuum

    • Supports all HTTP verbs

  • Web Message Encoding

    • JSON

    • XML

    • Binary (streams)


Webget and webinvoke

[WebGet] and [WebInvoke]

  • Indicate the HTTP Method for the operation

    • WebGet – Don’t make me write it

    • WebInvoke – All verbs other than GET (Method parameter takes in the name of the Verb)

  • Other Parameters

    • BodyStyle – Indicates whether the Request / Response are wrapped or not

    • RequestFormat – Json or Xml

    • ResponseFormat – Json or Xml

    • UriTemplate – Covered next …


Uritemplate

UriTemplate

  • String that allows you to define the structure of the URI, as well as to define “Holes”

    • The “Holes” are variables

    • You Bind the template with parameters to fill the holes

  • {productId} hole / variable gets bound to productId parameter in operation

Hole

[OperationContract]

[WebGet(UriTemplate=“product/{productId}")]

ProductGetProduct(intproductId);


Webget webinvoke examples

WebGet/WebInvoke Examples

[OperationContract]

[WebInvoke( Method=“PUT",

ResponseFormat=WebMessageFormat.Json,

UriTemplate=“product/{productId}")]

ProductUpdateProduct(intproductId, product p);

[OperationContract]

[WebGet(ResponseFormat=WebMessageFormat.Json,

UriTemplate=“product/{productId}")]

ProductDataGetProduct(intproductId);


Webhttpbinding endpoint behaviors

webHttpBinding Endpoint Behaviors

  • Endpoint Behaviors - extend run-time behavior for an endpoint

  • webHttp - enables the Web programming model for a WCF service

  • enableWebScript – ASP.NET AJAX friendly endpoint behavior

    • Aligns nicely with ASP.NET AJAX client

    • SubClasses webHttp

    • Provides ASP.NET AJAX proxy generation

    • Only supports GET and overloaded POST

    • Does not support UriTemplates


Implementing restful services with windows communication foundation 3 5 sp1

Demo

LO-REST (AJAX Friendly)


Implementing restful services with windows communication foundation 3 5 sp1

Demo

HI-REST


Summary

Summary

  • REST principles borrow from principles of the web

  • Architectures vary with regard to adherence to REST principles

  • webHttpBinding supports architectures across the REST continuum

    • enableWebScript

      • Productivity features for ASP.NET AJAX applications

      • Imposes limitations

    • webHttp – Provides ability to implement services that adhere to strictest of standards


Resources

Resources

  • "AJAX Integration and JSON support" in .Net 3.5 conceptual docs

  • "Web Programming Model" in .Net 3.5 conceptual docs

  • Posting of Various Valuable WCF Docs

  • Steve Maine's Blog

  • HTTP Programming with WCF and the .NET Framework 3.5 (MSDN Magazine)

  • WCF, WF and .NET 3.5 Whitepapers by David Chappell


  • Login