Programming WCF Services pdf

910 7.3K 4
Programming WCF Services pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

www.it-ebooks.info www.it-ebooks.info Programming WCF Services www.it-ebooks.info www.it-ebooks.info THIRD EDITION Programming WCF Services Juval Löwy Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo www.it-ebooks.info Programming WCF Services, Third Edition by Juval Löwy Copyright © 2010 Juval Löwy. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com. Editors: Mike Hendrickson and Laurel Ruma Production Editor: Teresa Elsey Proofreader: Teresa Elsey Indexer: Newgen North America, Inc. Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano Printing History: February 2007: First Edition. November 2008: Second Edition. August 2010: Third Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Programming WCF Services, Third Edition, the image of an angelfish, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein. ISBN: 978-0-596-80548-7 [M] 1281631550 www.it-ebooks.info To my family www.it-ebooks.info www.it-ebooks.info Table of Contents Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi 1. WCF Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 What Is WCF? 1 Services 2 Service Execution Boundaries 3 WCF and Location Transparency 4 Addresses 4 TCP Addresses 5 HTTP Addresses 6 IPC Addresses 6 MSMQ Addresses 7 Service Bus Addresses 7 Contracts 7 The Service Contract 8 Hosting 11 IIS 5/6 Hosting 12 Self-Hosting 13 WAS Hosting 19 Custom Hosting in IIS/WAS 19 Windows Server AppFabric 20 Choosing a Host 22 Bindings 24 The Common Bindings 25 Choosing a Binding 26 Additional Bindings 27 Using a Binding 29 Endpoints 29 Administrative Endpoint Configuration 30 vii www.it-ebooks.info Programmatic Endpoint Configuration 34 Default Endpoints 36 Metadata Exchange 39 Metadata over HTTP-GET 39 The Metadata Exchange Endpoint 42 The Metadata Explorer 49 More on Behavior Configuration 51 Client-Side Programming 53 Generating the Proxy 53 Administrative Client Configuration 57 Programmatic Client Configuration 64 The WCF-Provided Test Client 64 Programmatic Versus Administrative Configuration 67 WCF Architecture 67 Host Architecture 69 Working with Channels 70 The InProcFactory Class 71 Transport-Level Sessions 75 Transport Session and Binding 76 Transport Session Termination 76 Reliability 77 Bindings, Reliability, and Ordered Messages 78 Configuring Reliability 79 Requiring Ordered Delivery 80 2. Service Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Operation Overloading 83 Contract Inheritance 86 Client-Side Contract Hierarchy 87 Service Contract Factoring and Design 90 Contract Factoring 90 Factoring Metrics 93 Contract Queries 95 Programmatic Metadata Processing 95 The MetadataHelper Class 98 3. Data Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Serialization 103 .NET Serialization 105 The WCF Formatters 107 Data Contract via Serialization 110 Data Contract Attributes 111 Importing a Data Contract 113 viii | Table of Contents www.it-ebooks.info [...]... jobs run through WCF SOAP services When you create a new service namespace in our system, the messages flow between data centers using WCF SOAP services, creating resources in the places where you ask for them to be created Monitoring happens via WCF SOAP services; diagnostics happens via WCF SOAP services; billing data collection, consolidation, and handoff happens using WCF SOAP services xvii www.it-ebooks.info... intermediary such as the Windows Azure AppFabric Service Bus With WCF, messages are usually SOAP messages These messages are independent of transport protocols—unlike web services, WCF services may communicate over a variety of transports (not just HTTP) WCF clients may interoperate with non -WCF services, and WCF services can interact with non -WCF clients That said, if you develop both the client and the... developing and deploying services on Windows I will describe what a service is in the next section But WCF is much more—it is literally a better NET WCF provides a runtime environment for your services, enabling you to expose Common Language Runtime (CLR) types as services and to consume other services as CLR types Although in theory you could build services without WCF, in practice, building services is significantly... 160 162 163 164 165 4 Instance Management 169 Behaviors Per-Call Services Benefits of Per-Call Services Configuring Per-Call Services Per-Call Services and Transport Sessions Designing Per-Call Services Choosing Per-Call Services Per-Session Services Configuring Private Sessions Sessions and Reliability The Session ID Session Termination Singleton Service... developers should use WCF, regardless of their application types, sizes, or industry domains WCF is a fundamental technology that provides an easy and clean way to generate services and applications in compliance with what I regard as sound design principles WCF was engineered from the ground up to simplify application development and deployment and to lower the overall cost of ownership WCF services allow... build services without WCF, in practice, building services is significantly easier with WCF WCF is Microsoft’s implementation of a set of industry standards defining service interactions, type conversions, marshaling, and the management of various protocols Consequently, WCF provides interoperability between services WCF provides developers with the essential off-the-shelf plumbing required by almost... the quality of your WCF services ServiceModelEx is literally a small framework that sits on top of WCF and compensates for some oversights in its design ServiceModelEx also simplifies and automates certain tasks This book is as much about my tools, ideas, and techniques as it is about native xxii | Preface www.it-ebooks.info WCF, and my framework also demonstrates how you can extend WCF Many readers have... methods WCF allows the client to communicate with a service across all execution boundaries On the same machine, the client can consume services in the same app domain, across app domains in the same process, or across processes (see Figure 1-2) Figure 1-2 Same-machine communication using WCF Services | 3 www.it-ebooks.info Across machine boundaries (Figure 1-3), the client can interact with services. .. provide the client with the same programming model regardless of the location of the service However, the WCF approach is the exact opposite: it takes the remote programming model of instantiating and using a proxy and uses it even in the most local case Because all interactions are done via a proxy, requiring the same configuration and hosting, WCF maintains the same programming model for the local... the chapters and appendixes in this book: Chapter 1, WCF Essentials This first chapter starts by explaining what WCF is, then describes essential WCF concepts and building blocks (such as addresses, contracts, bindings, endpoints, hosting, and clients) and key concepts such as reliability and transport sessions The chapter includes a discussion of the WCF architecture, which is really the linchpin of . www.it-ebooks.info www.it-ebooks.info Programming WCF Services www.it-ebooks.info www.it-ebooks.info THIRD EDITION Programming WCF Services Juval Löwy Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo www.it-ebooks.info Programming. 169 Per-Call Services 171 Benefits of Per-Call Services 171 Configuring Per-Call Services 172 Per-Call Services and Transport Sessions 173 Designing Per-Call Services 174 Choosing Per-Call Services. created. Monitoring happens via WCF SOAP services; diagnostics happens via WCF SOAP services; billing data collection, consol- idation, and handoff happens using WCF SOAP services. xvii www.it-ebooks.info As

Ngày đăng: 29/03/2014, 22:20

Mục lục

  • Preface

    • How This Book Is Organized

    • Some Assumptions About the Reader

    • What You Need to Use This Book

    • Conventions Used in This Book

    • How to Contact O’Reilly

    • Chapter 1. WCF Essentials

      • What Is WCF?

      • WCF and Location Transparency

      • Contracts

        • The Service Contract

          • Applying the ServiceContract attribute

          • Hosting

            • IIS 5/6 Hosting

              • Using Visual Studio 2010

              • Self-hosting and base addresses

              • The ServiceHost<T> class

              • Custom Hosting in IIS/WAS

              • Bindings

                • The Common Bindings

                  • Format and encoding

                  • Endpoints

                    • Administrative Endpoint Configuration

                      • Using base addresses

                      • Programmatic Endpoint Configuration

                        • Binding configuration

                        • Metadata Exchange

                          • Metadata over HTTP-GET

                            • Enabling metadata exchange administratively

                            • Enabling metadata exchange programmatically

                            • The Metadata Exchange Endpoint

                              • Standard endpoints

                              • Adding MEX endpoints programmatically

                              • Streamlining with ServiceHost<T>

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan