Foreword.xvi
Introduction.1
Part I Introducing the Windows Communication Foundation
1 Prerequisites.7
Introduction 7
Partial Types 7
Generics8
Nullable Value Types . 11
The Lightweight Transaction Manager 13
Role Providers . 14
Summary17
References. 17
2 The Fundamentals 19
Background19
The Service Model26
A Software Resource. 31
Building a Service for Accessing the Resource 34
Using the Service52
Hosting the Service in IIS65
Changing How the Service Communicates 70
Summary74
References. 74
3 Data Representation.77
Background77
The XmlSerializer and the DataContractSerializer 79
The XML Fetish 83
Using the DataContractSerializer88
Exception Handling . 103
Summary 108
References 108
4 Sessions, Reliable Sessions, Queues, and Transactions.109
Introduction109
Reliable Sessions109
Reliable Sessions in Action 111
Session Management113
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
Introduction131
What Is Windows Workflow Foundation? 131
What Windows Workflow Foundation Is Not . 132
Activities. 132
Out of the Box Activities135
Creating Custom Activities136
Communicating with Activities143
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 Engine179
Rules as Conditions181
The ConditionedActivityGroup Activity183
Rules as Policy. 185
Summary 188
References 188
6 Using the Windows Communication Foundation and the Windows
Workflow Foundation Together.189
Introduction189
Consuming Services. 190
The Simple Case . 190
The General Case191
Orchestrating Services . 195
Exposing Workflows as Services 196
Publishing as a Web Service. 196
Hosting Inside a WCF Service . 200
Looking Ahead206
References 213
Part III Security
7 Security Basics.217
Introduction217
Basic Tasks in Securing Communications217
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 Server223
Transport Security in Action 223
Using Message Security230
Impersonation and Authorization 236
Impersonation 236
Authorization 239
Reversing the Changes to Windows. 248
Uninstalling the Certificates 249
Removing the SSL Configuration from IIS250
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
Introduction253
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 Security273
CardSpace and the Enterprise 286
Summary 290
References 290
9 Securing Applications with Information Cards.293
Introduction293
Developing for the Identity Metasystem . 293
Simple Demonstration of CardSpace295
Prerequisites for the CardSpace Samples . 296
1) Enable Internet Information Services and ASP.NET 2.0 296
2) Get X.509 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
Introduction338
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 XSI342
Authorizing Access to an Intranet Resource Using Windows
Identity343
Improving the Initial Solution 350
Adding STSs as the Foundation for Federation 358
Reconfiguring the Resource Access Service 372
Reconfiguring the Client376
Experiencing the Power of Federated, Claims-Based Identity with XSI. 378
Claims-Based Security and Federated Security380
Summary 381
References 381
Part IV Integration and Interoperability
11 Legacy Integration 385
Introduction385
COM+ Integration 385
Supported Interfaces386
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 MSMQ402
Creating a Windows Communication Foundation Service That
Integrates with MSMQ . 403
Creating the Request . 403
Creating the Service 404
Creating the Client 407
Testing411
Summary 412
12 Interoperability.413
Summary 415
References 416
Part V Extending the Windows Communication Foundation
13 Custom Behaviors.419
Introduction419
Extending the Windows Communication Foundation 419
Extending the Service Model with Custom Behaviors . 420
Declare What Sort of Behavior You Are Providing421
Attach the Custom Behavior to an Operation or Endpoint425
Inform the Windows Communication Foundation of the
Custom Behavior . 426
Implementing a Custom Behavior426
Declare . 426
Attach 427
Inform427
Implementing Each Type of Custom Behavior435
Operation Selector . 436
Parameter Inspector 438
Message Formatter . 440
Message Inspector442
Instance Context Provider445
Instance Provider446
Operation Invokers 447
Implementing a WSDL Export Extension448
Implementation Steps 448
Custom Behaviors in Action451
Summary 452
References 452
14 Custom Channels 453
Introduction453
Binding Elements . 453
Outbound Communication . 454
Inbound Communication 455
Channels Have Shapes 456
Channels Might Be Required to Support Sessions. 457
Matching Contracts to Channels458
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
Introduction481
Transport Channels . 481
Inbound Communication 482
Outbound Communication . 482
Message Encoders . 482
Completing the Stack482
Implementing a Transport Binding Element and an Encoder Binding
Element 484
The Scenario 484
The Requirements485
The TcpListener and the TcpClient Classes485
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
Introduction505
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 Stream531
Summary 535
References 535
17 Peer Communication.537
Introducing Peer Channel537
Using Structured Data in Peer-to-Peer Applications537
Leveraging the Windows Peer-to-Peer Networking Development
Platform 538
Understanding Windows Peer-to-Peer Networks539
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 Contracts551
Implementing the Service Contracts . 554
Configuring the Endpoints555
Directing Messages to a Specific Peer. 558
Custom Peer Name Resolution 560
Seeing Peer Channel Work 566
Peer Channel and People Near Me568
Summary 568
References 568
18 Representational State Transfer and Plain XML Services.569
Introduction569
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 Endpoint573
Implementation . 574
A Sample Application 574
Summary 579
References 579
Part VII The Lifecycle of Windows Communication Foundation Applications
19 Manageability.583
Introduction583
Instrumentation and Tools. 584
The Configuration System and the Configuration Editor . 585
The Service Configuration Editor587
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
Introduction623
Versioning Nomenclature 624
The Universe of Versioning Problems624
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
Introduction639
Adopting the Windows Communication Foundation . 639
Working with Windows Communication Foundation Addre