RESTful .NET

Book description

RESTful .NET is the first book that teaches Windows developers to build RESTful web services using the latest Microsoft tools. Written by Windows Communication Foundation (WFC) expert Jon Flanders, this hands-on tutorial demonstrates how you can use WCF and other components of the .NET 3.5 Framework to build, deploy and use REST-based web services in a variety of application scenarios.

RESTful architecture offers a simpler approach to building web services than SOAP, SOA, and the cumbersome WS- stack. And WCF has proven to be a flexible technology for building distributed systems not necessarily tied to WS- standards. RESTful .NET provides you with a complete guide to the WCF REST programming model for building web services consumed either by machines or humans. You'll learn how to:

  • Program Read-Only (GET) services
  • Program READ/WRITE services
  • Host REST services
  • Program REST feeds
  • Program AJAX REST clients
  • Secure REST endpoints
  • Use workflow to deliver REST services
  • Consume RESTful XML services using WCF
  • Work with HTTP
  • Work with ADO.NET Data Services (Astoria)

RESTful .NET introduces you to the ideas of REST and RESTful architecture, and includes a detailed discussion of how the Web/REST model plugs into the WCF architecture. If you develop with .NET, it's time to jump on the RESTful bandwagon. This book explains how.

"While REST is simple, WCF is not. To really understand and exploit this part of WCF requires a knowledgeable and experienced guide. I don't know anybody who's better suited for this role than Jon Flanders. ...Jon is first-rate at explaining complicated things. This book is the best introduction I've seen to creating and using these services with WCF."--David Chappell, Chappell & Associates

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Who This Book Is For
    2. How This Book Is Organized
    3. What You Need to Use This Book
    4. Conventions Used in This Book
    5. Using Code Examples
    6. How to Contact the Author
    7. Comments and Questions
    8. Acknowledgments
  3. 1. REST Basics
    1. Architecture of the World Wide Web
    2. SOAP
    3. REST
      1. Resources and URIs
        1. URI design
      2. Uniform Interface
      3. Resource Representations
        1. XML
        2. RSS/Atom
        3. XHTML
        4. JSON
        5. Other media types
    4. Implementing a Simple RESTful Service Example
      1. Resources
      2. URIs and Uniform Interface
      3. Representations
      4. Interaction
      5. Wrap-Up
    5. Processes
    6. Summary
  4. 2. WCF RESTful Programming Model
    1. Isn’t WCF All About SOAP?
    2. Channels and Dispatching
    3. HTTP Programming with WCF 3.0
    4. Web Programming in WCF 3.5
      1. WebHttpBinding
      2. WebHttpBehavior
      3. WebServiceHost
      4. WebOperationContext
      5. WebGetAttribute
    5. UriTemplate
      1. UriTemplate Literal Values
      2. UriTemplate Special Values
      3. UriTemplate QueryString
    6. Summary
  5. 3. Programming Read-Only Services
    1. Using WebGetAttribute and UriTemplate
    2. Data Formats
      1. Message
      2. DataContract
      3. XmlSerializer
      4. Hybrid Approach
    3. Summary
  6. 4. Programming Read/Write Services
    1. POST, PUT, and DELETE
    2. Using WebInvokeAttribute
      1. Resources
      2. URIs and Uniform Interface
      3. Representations
      4. Implementation
        1. POST
        2. PUT
        3. DELETE
        4. Full service implementation
    3. Summary
  7. 5. Hosting WCF RESTful Services
    1. WCF REST Hosting Isn’t a Special Case
    2. Self-Hosting
      1. Configuring, Opening, and Closing a ServiceHost
      2. Base Addresses
      3. ServiceHost Versus WebServiceHost
      4. Custom ServiceHost
    3. Hosting in IIS
      1. ASP.NET Compatibility
      2. Multiple Hostnames
      3. Removing the .svc File Extension
    4. Custom ServiceHostFactory
    5. Hosting Wrap-Up
    6. Summary
  8. 6. Programming Feeds
    1. Building a Feed with WCF
      1. SyndicationItem
      2. Formatters
    2. Exposing a Feed on a Live URI
    3. Feed Validation
    4. Adding Links to a Feed
    5. Summary
  9. 7. Programming Ajax and Silverlight Clients
    1. WCF Web Services and Ajax
    2. JSON
      1. JSON-Enabling a Service Endpoint
    3. ASP.NET Ajax
    4. Silverlight 1.0
    5. Silverlight 2.0
      1. Parsing XML in Silverlight 2.0
        1. Using XmlReader
        2. Using XDocument
        3. Using XmlSerialization
        4. XML parsing wrap-up
      2. Parsing JSON in Silverlight 2.0
      3. Consuming Feeds in Silverlight 2.0
      4. Cross-Domain Security in Silverlight 2.0
    6. Returning JSON and XML Conditionally with a Single Method
    7. Summary
  10. 8. Securing REST Endpoints
    1. Authenticating: Self-Hosted Endpoints
      1. Setting Endpoint Security: WebHttpBinding.Security’s Mode Property
      2. Setting Authentication Requirements: WebHttpBinding’s Transport Property
        1. Certificate authentication
        2. Windows authentication
        3. NTLM authentication
        4. Digest authentication
        5. Basic authentication
    2. Authenticating: Managed Hosting Endpoints
    3. Authorizing Endpoints
      1. Authorization with Impersonation
      2. Role-Based Authorization
        1. Using the PrincipalPermissionAttribute
        2. The ServiceAuthorizationManager class
    4. Summary
  11. 9. Using Workflow to Deliver REST Services
    1. Consuming REST Services from WF
    2. The SendActivity Instance
    3. The ReceiveActivity Instance
    4. Stateless Workflow Services
    5. Stateful Workflow Services
    6. Summary
  12. 10. Consuming RESTful XML Services Using WCF
    1. Defining the Client
      1. Generating the Contract
      2. Creating the Resource Representations
      3. Creating the ServiceContract
      4. Using the Service
    2. Client Extensibility
    3. Summary
  13. 11. Working with HTTP
    1. Programming HTTP with WCF
      1. IncomingWebRequestContext
      2. OutgoingWebResponseContext
      3. OutgoingWebRequestContext
      4. IncomingWebResponseContext
      5. Context Wrap-Up
    2. Status Codes
      1. 201 — Created
      2. 404 — Not Found
    3. Conditional GET
      1. LastModified
      2. ETags
    4. Caching
      1. Output Caching
      2. HttpContext.Cache
      3. Content-Type
    5. Summary
  14. A. WCF 3.5 SP1
    1. Atom Publishing Protocol
      1. AtomPub in WCF 3.5 SP1
    2. UriTemplate Changes
    3. Attribute-Free DataContract Serialization
    4. Summary
  15. B. ADO.NET Data Services
    1. Building an ADO.NET Data Service
    2. ADO.NET Data Services and AtomPub
      1. Query Option
      2. Custom Service Operations
      3. Intercepting
      4. Client Library
    3. Summary
  16. C. ADO.NET Entity Framework Walkthrough
    1. Creating the Data Model
  17. Index
  18. About the Author
  19. Colophon
  20. Copyright

Product information

  • Title: RESTful .NET
  • Author(s): Jon Flanders
  • Release date: November 2008
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596519209