Standardized Service Contract (693) Services Within The Same Service .

Transcription

Standardized Service Contract (693)"Services within the same service inventory are in compliance with the same contract design standards."Service Loose Coupling (695)"Service contracts impose low consumer coupling requirements and are themselves decoupled fromtheir surrounding environment."Service Abstraction (696)"Service contracts only contain essential information and information about services is limited to whatis published in service contracts."Service Reusability (697)"Services contain and express agnostic logic and can be positioned as reusable enterprise resources."Service Autonomy (699)"Services exercise a high level of control over their underlying runtime execution environment."Service Statelessness (700)"Services minimize resource consumption by deferring the management of state information whennecessary."Service Discoverability (702)"Services are supplemented with communicative meta data by which they can be effectivelydiscovered and interpreted."Service Composability (704)"Services are effective composition participants, regardless of the size and complexity of the composition."implement astandardized contractServiceLoose Couplingminimize dependenciesimplement generic andreusable logic and dardizedService Contractminimize the availabilityof meta informationimplement independentfunctional boundary andruntime ze composablabilityimplement adaptive andstate management-free logicimplement communicativemeta verability

Agnostic Capability [709] How can multipurpose service logic be made effectivelyconsumable and composable?Compatible Change [723]How can a service contract be modifiedwithout impacting consumers?Agnostic Context [710] How can multipurpose service logic be positioned as aneffective enterprise resource?Compensating Service Transaction [724]How can composition runtime exceptions beconsistently accommodated without requiringservices to lock resources?Agnostic Sub-Controller [711] How canagnostic, cross-entity composition logic beseparated, reused, and governed independently?Asynchronous Queuing [712] How can aservice and its consumers accommodateisolated failures and avoid unnecessarily lockingresources?Atomic Service Transaction [713] How cana transaction with rollback capability bepropagated across messaging-based services?Brokered Authentication [714] How can aservice efficiently verify consumer credentials ifthe consumer and service do not trust eachother or if the consumer requires access tomultiple services?Canonical Expression [715] How canservice contracts be consistently understoodand interpreted?Canonical Protocol [716] How can servicesbe designed to avoid protcol bridging?Canonical Resources [717] How canunnecessary infrastructure resource disparitybe avoided?Canonical Schema [718] How canservices be designed to avoid data modeltransformation?Composition Autonomy [725] How cancompositions be implemented to minimize lossof autonomy?Concurrent Contracts [726] How can aservice facilitate multi-consumer couplingrequirements and abstraction concerns at thesame time?Contract Centralization [727] How candirect consumer-to-implementation couplingbe avoided?Contract Denormalization [728] How can aservice contract facilitate consumer programswith differing data exchange requirements?Cross-Domain Utility Layer [729] How canredundant utility logic be avoided acrossdomain service inventories?Data Confidentiality [730] How can datawithin a message be protected so that it is notdisclosed to unintended recipients while intransit?Data Format Transformation [731]How can services interact with programs thatcommunicate with different data formats?Data Model Transformation [732] How canservices interoperate when using different datamodels for the same type of data?Canonical Schema Bus [719]Canonical Versioning [720] How can servicecontracts within the same service inventory beversioned with minimal impact?Data Origin Authentication [733] How cana service verify that a message originates from aknown sender and that the message has notbeen tampered with in transit?Capability Composition [721] How can aservice capability solve a problem that requireslogic outside of the service boundary?Decomposed Capability [734] How can aservice be designed to minimize the chances ofcapability logic deconstruction?Capability Recomposition [722]How can the same capability be used to helpsolve multiple problems?Decoupled Contract [735] How can a serviceexpress its capabilities independently of itsimplementation?(pattern list continued on inside back cover)

This page intentionally left blank

Praise for this Book“Microsoft’s diverse product line has long supported the service-oriented enterprise,but putting it all together into a cohesive whole can be daunting. From more establishedproducts, like Windows Communication Foundation, Windows Workflow Foundation,Microsoft Office SharePoint Server, and BizTalk Server, to newer offerings like WindowsAzure and AppFabric, the experts assembled here expose the sweet spots for each technology, talk through the high-level trade-offs, and offer a roadmap to a unifiedMicrosoft SOA story.”—Kevin P. Davis, Ph.D.Software Architect“This book excels in giving hands-on and in-depth expertise on the SOA architecturestyle with the .NET framework and the Azure cloud platform. It’s a practical guide fordevelopers, architects, and SOA implementers. A must read!”—Ricardo P. SchluterICT Architect, Parnassia Bavo Group“While the industry overall may have hyped ‘the cloud’ to the level it often seems tocure world hunger, SOA with .NET and Windows Azure helps cut through the questionsand hype and more clearly discusses the benefits and practical techniques for putting itto work in the real world. This book helps you understand the benefits associated withSOA and cloud computing, and also the techniques for connecting your current IT assetswith new composite applications and data running in the cloud. This book will help youunderstand modern middleware technologies and harness the benefits of the cloud bothon and off premises.”—Burley KawasakiDirector of Product Management, Microsoft“The authors have a combined SOA and .NET experience of several decades—whichbecomes obvious when reading this book. They don’t just lead you down one path witha single descriptive solution. Instead, the sometimes nasty trade-offs that architects facein their design decisions are addressed. These are then mapped to the Microsoft .NETplatform with clear code examples. A very refreshing look at this major contender in theSOA space and a definite must for the .NET SOA practitioner!”—Dr. Thomas RischbeckIT Architect, Innovation Process Technology

“In order to evolve as a software craftsman one must read excellent books that will helpyou grow and evolve in your profession. One of those books that every software craftsman interested in good design and best practices should read is SOA with .NET andWindows Azure. With this book, you will learn which design patterns will provide thebest solution for the kinds of software design problems you, as a developer or designer,face every day. This book has everything that software architects, software designers,and programmers need to know when building great quality software with Microsofttechnologies.“This will undoubtedly be one of those books that you reference repeatedly when starting new SOA projects. There is plenty of information that even those not working withtypical service-oriented architecture will find very useful. With plenty of real-life examples (code, design, and modeling), readers see in a practical manner how they could useSOA patterns to solve everyday software problems and be more productive. SOA with.NET and Windows Azure will fit in my top three books and will definitely be one ofthose that I will use in my everyday work.”—Arman KurtagicConsultant at Omegapoint AB

SOA with .NETand Windows Azure

This page intentionally left blank

SOA with .NETand Windows Azure Realizing Service-Orientation with the Microsoft PlatformDavid Chou, John deVadoss, Thomas Erl,Nitin Gandhi, Hanu Kommalapati, Brian Loesgen,Christoph Schittko, Herbjörn Wilhelmsen,Mickey WilliamsWith contributions fromScott Golightly, Darryl Hogan, Jeff King, Scott SeelyWith additional contributions by members of theMicrosoft Windows Azure and AppFabric teamsUPPER SADDLE RIVER, NJ BOSTON INDIANAPOLIS SAN FRANCISCONEW YORK TORONTO MONTREAL LONDON MUNICH PARIS MADRIDCAPETOWN SYDNEY TOKYO SINGAPORE MEXICO CITY

Many of the designations used by manufacturers and sellers to distinguish theirproducts are claimed as trademarks. Where those designations appear in thisbook, and the publisher was aware of a trademark claim, the designations havebeen printed with initial capital letters or in all capitals.The authors and publisher have taken care in the preparation of this book, butmake no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information orprograms contained herein.The publisher offers excellent discounts on this book when ordered in quantityfor bulk purchases or special sales, which may include electronic versionsand/or custom covers and content particular to your business, training goals,marketing focus, and branding interests. For more information, please contact:U.S. Corporate and Government Sales(800) 382-3419corpsales@pearsontechgroup.comFor sales outside the United States please contact:International Salesinternational@pearson.comEditor-in-ChiefMark L. TaubDevelopment EditorChristina Erl-DanielsManaging EditorKristy HartProject EditorBetsy HarrisSenior IndexerCheryl LenserProofreadersWilliams Woods PublishingAmy ChouPublishing CoordinatorKim BoedigheimerVisit us on the Web: informit.comThe Library of Congress Cataloging-in-Publication Data is on file.Copyright 2010 SOA Systems Inc.Cover DesignersThomas ErlIvana LeeAll rights reserved. This publication is protected by copyright, and permissionmust be obtained from the publisher prior to any prohibited reproduction,storage in a retrieval system, or transmis-sion in any form or by any means,electronic, mechanical, photocopying, recording, or likewise. For informationregarding permissions, write to:CompositorBumpy DesignPhotosThomas ErlPearson Education, IncDiagram DesignerRights and Contracts DepartmentChristina Erl-Daniels501 Boylston Street, Suite 900Boston, MA 02116Fax (617) 671 3447ISBN-13: 978-0-13-158231-6ISBN-10: 0-13-158231-3Text printed in the United States on recycled paper at Edward Brothers in Ann Arbor, Michigan.First printing May 2010

To my family for their unconditional love and support.And to everyone who encouraged and granted me opportunities to grow.—David ChouA big thank you to my wife and my two kuttis, Dipu and Gitu,for their support and for giving me time to work on this book.—John deVadossTo Nikolas, who joined our team last June and has proven himself an expertin the functional decomposition of anything he can get his hands on.—Thomas ErlDedicated to my kids Tanay and Tanisha.—Nitin GandhiI dedicate this book to my wife Vijayalakshmi and our daughtersAjitha and Akshatha for putting up with me when I worked long hourson this project while at the same time keeping a day job!I would also like to mention the hard work of my parentsYanadaiah and Anasuyamma but for whose help I would still bea farmer in rural South India.—Hanu KommalapatiI’d like to dedicate my contribution to this book to my wife Miriam and childrenSteven and Melissa, and thank them for their continual support and understanding.—Brian LoesgenTo Alex.—Christoph SchittkoTo my son and wife.—Herbjörn Wilhelmsen

This page intentionally left blank

ContentsForeword by S. Somasegar . . . . . . . . . . . . . . . . . . . . xxxiForeword by David Chappell . . . . . . . . . . . . . . . . . . xxxiiiAcknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . xxxvC HAPTER 1: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 11.1 About this Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Objectives of this Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Who this Book is For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 What this Book Does Not Cover . . . . . . . . . . . . . . . . . . . . . . 41.5 Prerequisite Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.6 How this Book is Organized . . . . . . . . . . . . . . . . . . . . . . . . . 6Part I: Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Chapter 3: SOA Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Chapter 4: A Brief History of Legacy .NET Distributed Technologies . . 7Chapter 5: WCF Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Chapter 6: WCF Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Chapter 7: .NET Enterprise Services Technologies . . . . . . . . . . . . . . . . 7Chapter 8: Cloud Services with Windows Azure . . . . . . . . . . . . . . . . . . 8Part II: Services and Service Composition . . . . . . . . . . . . . . . . . . . 8Chapter 9: Service-Orientation with .NET Part I:Service Contracts and Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . 8Chapter 10: Service-Orientation with .NET Part II:Coupling, Abstraction, and Discoverability . . . . . . . . . . . . . . . . . . . . . . 8Chapter 11: Service-Orientation with .NET Part III:Reusability and Agnostic Service Models . . . . . . . . . . . . . . . . . . . . . . . 8Chapter 12: Service-Orientation with .NET Part IV:Service Composition and Orchestration Basics . . . . . . . . . . . . . . . . . . . 9Chapter 13: Orchestration Patterns with WF. . . . . . . . . . . . . . . . . . . . . . 9Chapter 14: Orchestration Patterns with BizTalk Server . . . . . . . . . . . . 9

xContentsPart III: Infrastructure and Architecture . . . . . . . . . . . . . . . . . . . . . . 9Chapter 15: Enterprise Service Bus with BizTalk Server andWindows Azure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Chapter 16: Windows Azure Platform AppFabric Service Bus. . . . . . . 10Chapter 17: SOA Security with .NET and Windows Azure . . . . . . . . . . 10Chapter 18: Service-Oriented Presentation Layers with .NET . . . . . . . 10Chapter 19: Service Performance Optimization . . . . . . . . . . . . . . . . . 10Chapter 20: SOA Metrics with BAM . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Part IV: Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Appendix A: Case Study Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 10Appendix B: Industry Standards Reference . . . . . . . . . . . . . . . . . . . . . 11Appendix C: Service-Orientation Principles Reference . . . . . . . . . . . . 11Appendix D: SOA Design Patterns Reference . . . . . . . . . . . . . . . . . . 11Appendix E: The Annotated SOA Manifesto. . . . . . . . . . . . . . . . . . . . . 11Appendix F: Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.7 How Principles and Patterns are Used in this Book . . . . . . 11Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Reference Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.8 Symbols, Figures, and Style Conventions. . . . . . . . . . . . . . 13Symbol Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13How Color is Used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Updates, Errata, and Resources (www.soabooks.com) . . . . . . . . 13Master Glossary (www.soaglossary.com) . . . . . . . . . . . . . . . . . . . 13Referenced Specifications (www.soaspecs.com). . . . . . . . . . . . . 13SOASchool.com SOA Certified Professional (SOACP) . . . . . . . 14The SOA Magazine (www.soamag.com) . . . . . . . . . . . . . . . . . . . 14Notification Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14C HAPTER 2: Case Study Background . . . . . . . . . . . . . . . 152.1 How Case Studies Are Used. . . . . . . . . . . . . . . . . . . . . . . . 162.2 Case Study Background #1: Standard Mold . . . . . . . . . . . 16History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Technical Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Business Goals and Obstacles . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

xiContents2.3 Case Study Background #2: Superior Stamping . . . . . . . . 18History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Technical Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Business Goals and Obstacles . . . . . . . . . . . . . . . . . . . . . . . . . . . 19PART I: FUNDAMENTALSC HAPTER 3: SOA Fundamentals . . . . . . . . . . . . . . . . . . . 233.1 Basic SOA Terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Service-Oriented Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Service-Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Service-Oriented Architecture (SOA) . . . . . . . . . . . . . . . . . . . . . . 27Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Services as Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Services as Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Services as REST Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Service Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Agnostic Logic and Non-Agnostic Logic . . . . . . . . . . . . . . . . . . . . . . . 32Service Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Service Inventory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Service-Oriented Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Service Candidate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Service-Oriented Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Service Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Service-Related Granularity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37SOA Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383.2 Service-Oriented Computing Goals . . . . . . . . . . . . . . . . . . 40Increased Intrinsic Interoperability . . . . . . . . . . . . . . . . . . . . . . . . 40Increased Federation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Increased Vendor Diversification Options. . . . . . . . . . . . . . . . . . . 40Increased Business and Technology Domain Alignment . . . . . . . 413.3 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

xiiContentsC HAPTER 4: A Brief History of Legacy .NETDistributed Technologies . . . . . . . . . . . . . . . . . . . . . . . 434.1 Distributed Computing 101 . . . . . . . . . . . . . . . . . . . . . . . . . 44Client-Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Distributed Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Service-Oriented Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . 474.2 .NET Enterprise Services . . . . . . . . . . . . . . . . . . . . . . . . . . 48It All Began with COM (and DCOM) . . . . . . . . . . . . . . . . . . . . . . . 48COM Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49.NET Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Distributed Transaction Coordinator . . . . . . . . . . . . . . . . . . . . . . . 51.NET Enterprise Services and Service-Orientation . . . . . . . . . . . . 534.3 .NET Remoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54.NET Remoting Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Serializable Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Remotable Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Ordinary Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Hosting .NET Remoting Components . . . . . . . . . . . . . . . . . . . . . . 56Windows Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56IIS Hosting Under ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Hosting a .NET Remoting Component in a Console Application . . . . . 57.NET COM Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57.NET Remoting Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Activation Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Message Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Communication Protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Object Lifetime Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.NET Remoting and Service-Orientation . . . . . . . . . . . . . . . . . . . . 614.4 Microsoft Messaging Queue (MSMQ). . . . . . . . . . . . . . . . . 63The Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64Sending and Receiving Messages . . . . . . . . . . . . . . . . . . . . . . . . 65MSMQ and Service-Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . 664.5 System.Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67Distributed Resource Transactions . . . . . . . . . . . . . . . . . . . . . . . . 67Explicit and Implicit Programming Models . . . . . . . . . . . . . . . . . . 68Ambient Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Contentsxiii4.6 Web Services (ASMX and WSE) . . . . . . . . . . . . . . . . . . . . . 70XML Web Services (ASMX) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71The WebService Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71The WebMethod Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72Web Service Enhancements (WSE) . . . . . . . . . . . . . . . . . . . . . . . 734.7 REST Service Processing with IHttpHandler. . . . . . . . . . . . 74C HAPTER 5: WCF Services . . . . . . . . . . . . . . . . . . . . . . . 755.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765.2 Service Contracts with WCF . . . . . . . . . . . . . . . . . . . . . . . . 78WCF Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78WCF Service Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Interface Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Operation Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Data Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Message Contract. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79Service Endpoint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79The ServiceContract and OperationContract Attributes . . . . . . . . 79Data Models and the DataContract Attribute . . . . . . . . . . . . . . . . 82Messaging and the MessageContract Attribute . . . . . . . . . . . . . . 83Service Endpoints and the endpoint Element . . . . . . . . . . . . . . . . 86Address. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92REST Service Classes and Attributes . . . . . . . . . . . . . . . . . . . . . . 92The WebGet Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93The WebInvoke Attribute. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95WCF UriTemplate Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96Faults and the FaultContract Attribute . . . . . . . . . . . . . . . . . . . . . 98MEX Endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100Versioning Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1025.3 Service Implementation with WCF . . . . . . . . . . . . . . . . . . 104Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104Instancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105A Sample Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

xivContents5.4 Service Hosting with WCF. . . . . . . . . . . . . . . . . . . . . . . . . 108Self-Hosted Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110Managed Windows Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . 112IIS Process Boundary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Windows Activation Services (WAS) . . . . . . . . . . . . . . . . . . . . . . 114Hosting REST Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1155.5 Service Consumers with WCF. . . . . . . . . . . . . . . . . . . . . . 116Using the Service Metadata Tool . . . . . . . . . . . . . . . . . . . . . . . . 117Writing the Proxy Class for a Service . . . . . . . . . . . . . . . . . . . . . 118Using the ChannelFactory Class. . . . . . . . . . . . . . . . . . . . . . . . . 119C HAPTER 6: WCF Extensions . . . . . . . . . . . . . . . . . . . . 1216.1 WCF Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122Security Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125Federated Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1266.2 WCF Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127Operation Attributes for Transactions . . . . . . . . . . . . . . . . . . . . . 127TransactionScopeRequired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128TransactionAutoComplete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128TransactionFlow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128Service Attributes for Transactions . . . . . . . . . . . . . . . . . . . . . . . 129TransactionIsolationLevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129TransactionAutoCompleteOnSessionClose . . . . . . . . . . . . . . . . . . . . 130TransactionTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130Durable Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1316.3 WCF Router . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132The RoutingService Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Routing Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134Routing Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135Step 1: Define Endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135Step 2: Configure Service Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . 136Step 3: Enumerate Target Endpoints . . . . . . . . . . . . . . . . . . . . . . . . . 136Step 4: Define Message Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137Step 5: Create a Filter Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138Fault Tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

Contentsxv6.4 WCF Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140Discovery Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141Locating a Service Ad Hoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143Sending and Receiving Service Announcements. . . . . . . . . . . . 144Discovery Proxies for Managed Discovery . . . . . . . . . . . . . . . . . 146Discovering from a Discovery Proxy. . . . . . . . . . . . . . . . . . . . . . . . . . 146Implicit Service Discovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1476.5 WCF Extensibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148WCF Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Layered Extensibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Channel Layer Extensibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1506.6 WCF Management Tools . . . . . . . . . . . . . .

Service Loose Coupling (695) "Service contracts impose low consumer coupling requirements and are themselves decoupled from their surrounding environment." Service Abstraction (696) "Service contracts only contain essential information and information about services is limited to what is published in service contracts." Service Reusability (697)