Windows Communication Foundation Unleashed (WCF)
Read an excerpt:
Chapter 1: Prerequisites
Reprinted with permission from Sams Publishing. Copyright © Pearson Education, Sams Publishing. Written permission from the publisher is required for any use of this material.
|
Be the First to Write a Review and tell the world about this title!People who purchase this book frequently purchase: Books on similar topics, in best-seller order:Books from the same publisher, in best-seller order:
Windows Communication Foundation (WCF) is a new Microsoft
technology for allowing software to communicate. Superseding earlier technologies,
such as COM/DCOM, .NET Remoting, ASP.NET Web Services, and the Web Services
Enhancements for .NET, WCF provides a single solution that is designed to
always be the best way to exchange data among software entities. It also
provides the infrastructure for developing the next generation of Web services,
with support for the WS-* family of specifications, and a new serialization
system for enhanced performance. For information technology professionals,
WCF supplies an impressive array of administration tools that enterprises
and software vendors can use to reduce the cost of ownership of their solutions
without writing a single line of code. Most important, WCF finally delivers
on the long-postponed promise of model-driven software development with
the new software factory approach, by which one can iteratively design solutions
in a modeling language and generate executables from lower-level class libraries.
Windows Communication Foundation Unleashed is
designed to be the best resource for software developers and architects
working with WCF. The book guides readers toward a conceptual understanding
of all the facilities of WCF and provides step-by-step guides to applying
the technology to practical problems.
• Introduces you to WCF and then takes you deep inside the
technology
• Gives you nearly 100 best practices for programming
with WCF
• Provides detailed coverage on how to version services
that you will not find anywhere else
• Delves into using WCF together with Windows Workflow
Foundation and Windows CardSpace
• Provides detailed coverage of the new high-performance
data contract serializer for .NET
• Walks you through how to do secure, reliable, transacted
messaging, and how to understand the options available
• Introduces you to federated, claims-based security,
and shows you how to incorporate SAML and WS-Trust security token services into
your architecture
• Provides step-by-step instructions for how to customize
every aspect of WCF
• Shows you how to add your own behaviors, communication
channels, message encoders, and transports
• Gives you options for implementing publish/subscribe
solutions
• Walks you through how to do peer-to-peer communications
with WCF
As evangelists at Microsoft for WCF, Craig McMurtry,
Marc Mercuri, Nigel Watling, and Matt Winkler are uniquely positioned to
write this book. They had access to the product as it was being built and
to the development team itself. Their work with enterprises and outside
software vendors has given them insight into how others see the software,
how they want to apply it, and the challenges they face in doing so.
Table of Contents
Foreword
xvi
Introduction
1
Part I Introducing
the Windows Communication Foundation
1 Prerequisites
7
Introduction 7
Partial Types 7
Generics
. 8
Nullable Value Types
11
The Lightweight Transaction
Manager
13
Role Providers
14
Summary
17
References 17
2 The Fundamentals
19
Background 19
The Service Model 26
A Software Resource 31
Building a Service
for Accessing the Resource 34
Using the Service 52
Hosting the Service
in IIS 65
Changing How the Service
Communicates
70
Summary
74
References 74
3 Data Representation 77
Background 77
The XmlSerializer and
the DataContractSerializer 79
The XML Fetish
. 83
Using the DataContractSerializer . 88
Exception Handling
103
Summary
108
References
108
4 Sessions, Reliable
Sessions, Queues, and Transactions 109
Introduction
109
Reliable Sessions 109
Reliable Sessions in
Action 111
Session Management 113
Queued Delivery
114
Enhancements in Windows
Vista 116
Transactions 118
Summary
128
Part II Introducing
the Windows Workflow Foundation
5 Fundamentals of the
Windows Workflow Foundation 131
Introduction
131
What Is Windows Workflow
Foundation?
131
What Windows Workflow
Foundation Is Not 132
Activities 132
Out of the Box Activities 135
Creating Custom Activities 136
Communicating with
Activities 143
Design Behavior
149
Transactions and Compensation
151
Workflow Models
154
Sequential Workflows
155
State Machine Workflows 163
Custom Root Activities
165
Workflow Hosting 166
Hosting the Runtime 166
Runtime Services 168
Custom Services
177
Rules Engine
179
Rules as Conditions 181
The ConditionedActivityGroup
Activity
183
Rules as Policy
185
Summary
188
References
188
6 Using the Windows
Communication Foundation and the Windows
Workflow Foundation
Together 189
Introduction
189
Consuming Services 190
The Simple Case
190
The General Case
191
Orchestrating Services
195
Exposing Workflows
as Services
196
Publishing as a Web
Service 196
Hosting Inside a WCF
Service
200
Looking Ahead 206
References
213
Part III Security
7 Security Basics 217
Introduction
217
Basic Tasks in Securing
Communications 217
Transport Security
and Message Security
218
Using Transport Security 219
Installing Certificates
219
Identifying the Certificate
the Server Is to Provide 221
Configuring the Identity
of the Server
223
Transport Security
in Action 223
Using Message Security 230
Impersonation and Authorization
236
Impersonation 236
Authorization 239
Reversing the Changes
to Windows 248
Uninstalling the Certificates
249
Removing the SSL Configuration
from IIS
250
Removing the SSL Configuration
from HTTP.SYS 250
Restoring the Identity
of the Server 250
Summary
251
References
251
8 Windows CardSpace,
Information Cards, and the Identity Metasystem 253
Introduction
253
The Role of Identity
253
Microsoft Passport
and Other Identity Solutions
256
The Laws of Identity
258
The Identity Metasystem
259
Information Cards and
CardSpace 265
Managing Information
Cards 267
Architecture, Protocols,
and Security
273
CardSpace and the Enterprise
286
Summary
290
References
290
9 Securing Applications
with Information Cards 293
Introduction
293
Developing for the
Identity Metasystem
293
Simple Demonstration
of CardSpace
295
Prerequisites for the
CardSpace Samples 296
1) Enable Internet
Information Services and ASP.NET 2.0 296
2) Get X509 Certificates
297
3) Import the Certificates
Into the Certificate Store 297
4) Update the Hosts
File with DNS Entries to Match the
Certificates 298
5) Internet Information
Services Setup 298
6) Certificate Private
Key Access 299
7) HTTP Configuration
300
Adding Information
Cards to a WCF Application 301
Adding Information
Cards 306
Using a Federation
Binding
311
Catching Exceptions
313
Processing the Issued
Token 314
Using the Metadata
Resolver
316
Adding Information
Cards to Browser Applications 317
Creating a Managed
Card
328
Building a Simple Security
Token Service 332
Summary
334
References
335
10 Advanced Security .337
Prelude
337
Introduction
338
Securing Resources
with Claims
338
Claims-Based Authorization
Versus Role-Based Authorization 339
Claims-Based Authorization
Versus Access Control Lists 340
Adopting Claims-Based
Authorization 341
Leveraging Claims-Based
Security Using XSI 342
Authorizing Access
to an Intranet Resource Using Windows
Identity
343
Improving the Initial
Solution
350
Adding STSs as the
Foundation for Federation 358
Reconfiguring the Resource
Access Service 372
Reconfiguring the Client 376
Experiencing the Power
of Federated, Claims-Based Identity with XSI
378
Claims-Based Security
and Federated Security 380
Summary
381
References
381
Part IV Integration
and Interoperability
11 Legacy Integration
385
Introduction
385
COM+ Integration 385
Supported Interfaces 386
Selecting the Hosting
Mode
387
Using the COM+ Service
Model Configuration Tool
387
Exposing a COM+ Component
as a Windows Communication
Foundation Web Service
390
Referencing in the
Client 395
Calling a Windows Communication
Foundation Service from COM 396
Building the Service
397
Building the Client
400
Building the VBScript
File
401
Testing the Solution
402
Integrating with MSMQ 402
Creating a Windows
Communication Foundation Service That
Integrates with MSMQ
403
Creating the Request
403
Creating the Service
404
Creating the Client
407
Testing
411
Summary
412
12 Interoperability 413
Summary
415
References
416
Part V Extending
the Windows Communication Foundation
13 Custom Behaviors 419
Introduction
419
Extending the Windows
Communication Foundation
419
Extending the Service
Model with Custom Behaviors
420
Declare What Sort of
Behavior You Are Providing 421
Attach the Custom Behavior
to an Operation or Endpoint 425
Inform the Windows
Communication Foundation of the
Custom Behavior
426
Implementing a Custom
Behavior
426
Declare
426
Attach
427
Inform 427
Implementing Each Type
of Custom Behavior 435
Operation Selector
436
Parameter Inspector
438
Message Formatter 440
Message Inspector 442
Instance Context Provider 445
Instance Provider 446
Operation Invokers
447
Implementing a WSDL
Export Extension
448
Implementation Steps
448
Custom Behaviors in
Action 451
Summary
452
References
452
14 Custom Channels 453
Introduction
453
Binding Elements 453
Outbound Communication
454
Inbound Communication
455
Channels Have Shapes
456
Channels Might Be Required
to Support Sessions 457
Matching Contracts
to Channels 458
Communication State
Machines
460
Building Custom Binding
Elements
461
Understand the Starting
Point 461
Provide a Custom Binding
Element That Supports Outbound
Communication 463
Amend the Custom Binding
Element to Support Inbound Communication
470
Applying a Custom Binding
Element Through Configuration 476
Summary
480
15 Custom Transports 481
Introduction
481
Transport Channels
481
Inbound Communication
482
Outbound Communication
482
Message Encoders 482
Completing the Stack 482
Implementing a Transport
Binding Element and an Encoder Binding
Element
484
The Scenario 484
The Requirements
485
The TcpListener and
the TcpClient Classes
485
Implementing Custom
Binding Elements to Support an Arbitrary
TCP Protocol 488
The Configuration 488
The Custom Transport
Binding Element
490
The Channel Listener
493
The Transport Channel 496
The Message Encoder
499
Using the Custom Transport
Binding Element 500
Summary
501
References
501
Part VI Special
Cases
16 Publish/Subscribe
Systems 505
Introduction
505
Publish/Subscribe Using
Callback Contracts 506
Publish/Subscribe Using
MSMQ Pragmatic Multicasting
513
Publish/Subscribe Using
Streaming 521
The Streamed Transfer
Mode
522
Transmitting a Custom
Stream with the Streamed
Transfer Mode 526
Implementing Publish/Subscribe
Using the Streamed
Transfer Mode and a
Custom Stream
531
Summary
535
References
535
17 Peer Communication 537
Introducing Peer Channel 537
Using Structured Data
in Peer-to-Peer Applications
537
Leveraging the Windows
Peer-to-Peer Networking Development
Platform 538
Understanding Windows
Peer-to-Peer Networks
539
Using Peer Channel
539
Endpoints 539
Binding
540
Address
543
Contract 544
Implementation
544
Peer Channel in Action
545
Envisaging the Solution
545
Designing the Data
Structures 549
Defining the Service
Contracts
551
Implementing the Service
Contracts 554
Configuring the Endpoints 555
Directing Messages
to a Specific Peer 558
Custom Peer Name Resolution
560
Seeing Peer Channel
Work
566
Peer Channel and People
Near Me 568
Summary
568
References
568
18 Representational
State Transfer and Plain XML Services
569
Introduction
569
Representational State
Transfer
569
REST Services 570
REST Services and Plain
XML
570
The Virtues and Limitations
of REST Services
571
Building REST POX Services
with the Windows Communication
Foundation
572
The Address of a REST
POX Service Endpoint
572
The Binding of a REST
POX Service Endpoint
572
The Contract of a REST
POX Service Endpoint
573
Implementation
574
A Sample Application
574
Summary
579
References
579
Part VII The Lifecycle
of Windows Communication Foundation Applications
19 Manageability
583
Introduction
583
Instrumentation and
Tools
584
The Configuration System
and the Configuration Editor 585
The Service Configuration
Editor 587
Configurable Auditing
of Security Events 594
Message Logging, Activity
Tracing, and the Service Trace
Viewer
597
Performance Counters
608
WMI Provider 610
Completing the Management
Facilities 621
Summary
621
References
621
20 Versioning .623
Introduction
623
Versioning Nomenclature
624
The Universe of Versioning
Problems
624
Adding a New Operation
625
Changing an Operation
626
Deleting an Operation
630
Changing a Binding
630
Deciding to Retire
an Endpoint
631
Changing the Address
of a Service Endpoint 631
Centralized Lifecycle
Management 632
Summary
634
References
635
Part VIII Guidance
21 Guidance
.639
Introduction
639
Adopting the Windows Communication
Foundation 639
Working with Windows Communication
Foundation Addresses 641
Working with Windows
Communication Foundation Bindings 643
Working with Windows Communication
Foundation Contracts 646
Working with Structural
Contracts 649
Working with Behavioral
Contracts 652
Working with Windows Communication
Foundation Services 654
Ensuring Manageability
658
Working with Windows
Communication Foundation Clients 662
Working with Large
Amounts of Data
669
Debugging Windows Communication
Foundation Applications 671
Summary
672
References 672
Index 673
|