Programming wcf services mastering appfabric 3811 pdf

910 361 0
Programming wcf services mastering appfabric 3811 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

Download from Library of Wow! eBook Download from Library of Wow! eBook Programming WCF Services Download from Library of Wow! eBook Download from Library of Wow! eBook THIRD EDITION Programming WCF Services Juval Lưwy Beijing • Cambridge • Farnham • Kưln • Sebastopol • Taipei • Tokyo Download from Library of Wow! eBook 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: November 2008: August 2010: First Edition Second Edition 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 contained herein ISBN: 978-0-596-80548-7 [M] 1281631550 Download from Library of Wow! eBook To my family Download from Library of Wow! eBook Download from Library of Wow! eBook Table of Contents Foreword xvii Preface xxi WCF Essentials What Is WCF? Services Service Execution Boundaries WCF and Location Transparency Addresses TCP Addresses HTTP Addresses IPC Addresses MSMQ Addresses Service Bus Addresses Contracts The Service Contract Hosting IIS 5/6 Hosting Self-Hosting WAS Hosting Custom Hosting in IIS/WAS Windows Server AppFabric Choosing a Host Bindings The Common Bindings Choosing a Binding Additional Bindings Using a Binding Endpoints Administrative Endpoint Configuration 4 6 7 11 12 13 19 19 20 22 24 25 26 27 29 29 30 vii Download from Library of Wow! eBook Programmatic Endpoint Configuration Default Endpoints Metadata Exchange Metadata over HTTP-GET The Metadata Exchange Endpoint The Metadata Explorer More on Behavior Configuration Client-Side Programming Generating the Proxy Administrative Client Configuration Programmatic Client Configuration The WCF-Provided Test Client Programmatic Versus Administrative Configuration WCF Architecture Host Architecture Working with Channels The InProcFactory Class Transport-Level Sessions Transport Session and Binding Transport Session Termination Reliability Bindings, Reliability, and Ordered Messages Configuring Reliability Requiring Ordered Delivery 34 36 39 39 42 49 51 53 53 57 64 64 67 67 69 70 71 75 76 76 77 78 79 80 Service Contracts 83 Operation Overloading Contract Inheritance Client-Side Contract Hierarchy Service Contract Factoring and Design Contract Factoring Factoring Metrics Contract Queries Programmatic Metadata Processing The MetadataHelper Class 83 86 87 90 90 93 95 95 98 Data Contracts 103 Serialization NET Serialization The WCF Formatters Data Contract via Serialization Data Contract Attributes Importing a Data Contract viii | Table of Contents Download from Library of Wow! eBook 103 105 107 110 111 113 message contracts, message headers client-side interaction, 702 encapsulating, 704–707 instance IDs in, 203 overview, 701 server-side interaction, 704 streamlining client, 708 message pump, 400 message reliability, 77 Message Transport Optimization Mechanism (MTOM), 24 MessageBufferClient class, 638, 642, 649 MessageBufferPolicy class, 636 MessageQueue class, 466 messages defined, deserializing, 105 operational considerations, 24 ordered delivery, 78, 80 streaming, 251, 252 transfer security, 527–532 transport sessions and, 173, 669 metadata exchange class hierarchy, 123 enabling administratively, 39 enabling programmatically, 40–42 fault handling, 265 Metadata Explorer tool, 49, 97, 742, 748, 772 MetadataHelper, 98 over HTTP-GET, 39 processing programmatically, 95–97 publishing considerations, 3, 39 queued calls and, 471 ServiceBusMetadataHelper, 666 metadata exchange endpoints (see MEX (metadata exchange) endpoints) Metadata Explorer tool, 49, 97, 742, 748, 772 MetadataExchangeBindings class, 665 MetadataExchangeClient class functionality, 96, 97 GetMetadata() method, 96, 100 and service bus authentication, 665 MetadataHelper class, 838 functionality, 98–101 GetAddresses() method, 101 GetContracts() method, 101 GetEndpoints() method, 100, 101 GetOperations() method, 101 QueryContract() method, 98, 100 QueryMexEndpoint() method, 100 MetadataImporter class, 96 MetadataResolver class, 97 MetadataSet class, 96 MethodImpl attribute, 387 metrics, factoring, 93 MEX (metadata exchange) endpoints adding programmatically, 46 behavior configuration, 51 discovery and, 736 Metadata Explorer tool, 49 overview, 42 ServiceHost class, 47 standard endpoints, 44 MSMQ (Microsoft Message Queue) binding support, 25, 28 MSMQ addresses, poison messages, 495–501 promoting transactions, 310 transport transfer security, 528 types of queues, 464 MSMQ addresses, MSMQ workgroup installation, 465 MsmqBindingBase class DeadLetterQueue property, 488 delivery failures, 486 Durable property, 477 ExactlyOnce property, 477 playback failures, 495 TimeToLive property, 487 MsmqIntegrationBinding class, 28 MsmqMessageProperty class, 491 MTOM (Message Transport Optimization Mechanism), 24 mutual authentication, 527 N namespaces configuring endpoints, 31 contracts and, 11 reserving port, 17 service bus, 620 NET formatters, 106 serialization, 105 synchronization context, 397–399 transactional memory, 371 864 | Index Download from Library of Wow! eBook net.msmq protocol, net.pipe protocol, net.tcp protocol, NetDataContractSerializer class, 109 NetDispatcherFaultException, 150 NetEventRelayBinding class, 633 NetMsmqBinding class functionality, 25 operations support, 226 queued calls, 462 reliability and, 78 response service and, 506 transfer security, 530, 533, 541 transport schemes, 26 NetNamedPipeBinding class callback operations, 230 functionality, 25 IPC binding, 25 per-session services, 179, 181 reliability and, 78, 302 transfer security, 530, 533, 539 transport schemes, 26 NetNamedPipeContextBinding class, 369, 717–722, 850 NetNamedPipeContextBinding Element class, 850 NetNamedPipeContextBindingCollectionEle ment class, 850 NetPeerTcpBinding class, 28, 226 NetTcpBinding class binding configuration, 36 callback operations, 230 functionality, 25 per-session services, 179, 181 reliability and, 78, 79, 302 transfer security, 530, 533, 537 transport schemes, 26 NetTcpContextBinding class, 27 NetTcpRelayBinding class, 626 NetworkStream class, 251 None transaction mode, 322, 376 NonSerialized attribute, 105 nontransactional queues, 476 O ObjectDisposedException, 239, 256 OleTx protocol, 305 OnDeserialized attribute/event, 120 OnDeserializing attribute/event, 120, 149 one-way operations, 676 asynchronous calls, 452 AsyncOneWayClientBase, 453 configuring, 226 exceptions and, 228 functionality, 226 per-session services and, 227 reliability and, 227 transaction propagation, 304 one-way relay bindings, 631 OneWayClientBase class, 683, 849 OnSerialized attribute/event, 120 OnSerializing attribute/event, 120 OpenForms collections, 408 operation behaviors, 170 operation call context, 184 operation contracts, 302–304 operation overloading, 83–85 OperationBehavior attribute callbacks, 376 functionality, 170 ReleaselnstanceMode property, 193 TransactionAutoComplete property, 324 TransactionScopeRequired property, 317, 320, 325 OperationContext class Current method, 184, 232 GetCallbackChannel() method, 235 Host property, 188 InstanceContext property, 197 SessionId property, 184 SetTransactionComplete() method, 326, 327 OperationContract attribute Action property, 87, 88 AsyncPattern property, 441 callback operations, 231 functionality, IsInitiating property, 191, 192 IsOneWay property, 226, 227 IsTerminating property, 191, 192 Name property, 11, 84 ReplyAction property, 87, 88 TransactionFlowEnabled property, 318 OperationInterceptorBehaviorAttribute class, 853 operations callback, 230–247 defined, Index | 865 Download from Library of Wow! eBook demarcating, 190–192 events and, 247–251 one-way, 226–230 request-reply, 225 streaming, 251–254 OperationSecurityCallStackAttribute class, 854 OptionalField attribute, 151 Oracle, 310 ordered delivery bindings and, 78 requiring, 80 out-of-band callbacks, 379 overloading, operation, 83 P parallel task library, 403 peer networks, 28 per-call services benefits, 171 choosing, 177 cleanup operations, 176 concurrency management, 392 configuring, 172 connection management, 240 defined, 169 designing, 174 instance management, 169, 171–177, 345– 348 performance and, 176 queued services, 478 transport sessions and, 173 per-session services completing on session end, 357–359 concurrency management, 393 concurrent transactions, 356 configuring, 178–182 connection management, 241 defined, 169 disabling service instance release, 353 hybrid state management, 360–362 instance deactivation, 193–198 instance management, 169, 177–185 one-way operations and, 227 overview, 348 private-session mode, 177 queued services, 480–482 releasing service instance, 348–353 reliability, 182 session ID, 184, 185 state-aware services, 354 terminating, 185 transaction lifecycle, 356 transactional affinity, 359 performance, per-call services and, 176 persistence providers custom, 215 DurableService attribute, 214, 365 FileInstanceStore class, 215 PersistenceProvider class, 214, 215 PersistenceProviderFactory class, 214 SQL Server, 216 SqlPersistenceProvider class, 216 SqlPersistenceProviderFactory class, 216 PersistenceProvider class, 214, 215 PersistenceProviderFactory class, 214 persistent subscribers, 777, 781–784, 790 PersistentSubscription class, 852 PersistentSubscriptionManager class, 852 PersistentSubscriptionServiceClient class, 852 plain old CLR object (POCO), 118 playback failures, 494–501 POCO (plain old CLR object), 118 poison messages, 495–501 polling asynchronous calls, 445–447 port numbers HTTP addresses, relay bindings, 633 reserving namespace, 17 priority processing, 425–428 PriorityCallsBehaviorAttribute class, 426, 845 PriorityClientBase class, 427, 845 PriorityContext class, 845 PrioritySynchronizer class, 426, 845 private keys, 568 private queues, private-session mode configuring, 178–182 defined, 177 programmatic configuration, 67 promoting transactions, 310 protocol mapping, 38 proxies Abort() method, 258 asynchronous calls, 440 call timeout, 63 ChannelFactory class, 70 channels and, 67 866 | Index Download from Library of Wow! eBook ClientBase class, 61, 184 closing, 62, 259 Dispose() method, 62 duplex, 233, 241–244 generating, 53–57 location transparency, operation overloading, 84 proxy chaining, 89 and queued services, 511 WcfTestClient.exe, 66 proxy chaining, 89 public keys, 568 public queues, 7, 464 publisher service background, 775 defined, 247 design pattern, 776 event management, 247–251 framework, 777–808 metadata, 3, 39 publishers, 632 PublishService class, 852 Q queued calls architecture, 463 configuration/setup, 464–471 load balancing, 500 NetMsmgBinding class, 462 queued contracts, 463 queued services client-side, 467, 471 coding standard, 833 concurrency management, 484 connected calls and, 501–504 delivery, 471–476 delivery failures, 485–494 disconnections, 461 HTTP bridge, 518–522 instance management, 477–484 nontransactional, 476 playback, 471–476 playback failures, 494–501 publishers and subscribers, 792 purging, 469 queued calls, 462–471 response address to proxy, 511 response service, 504–517 service-side programming, 512 throttling and, 485 transactions, 471–477, 514–517 QueuedServiceHelper class, 467, 470, 846 R ReceiveContext class, 500 ReceiveErrorHandling enumeration Drop value, 497 Fault value, 496 Move value, 497 Reject value, 497 reentrancy, 390 relative addresses, 43 relative URIs, 14, 32 relay service defined, 618 RelayClientAuthenticationType enum, 663 relayed TCP connection mode, 628 ReleaseInstanceMode enumeration AfterCall value, 195, 196 BeforeAndAfterCall value, 196, 197 BeforeCall value, 194, 196 None value, 194, 196 reliability bindings and, 78 configuring, 79 message, 77, 78 one-way operations and, 227 service bus, 620 sessions and, 182 transactions and, 302 transport, 77 ReliableSession class, 76, 79 request-reply operations, 225 resolvers data contract, 129–141 generic resolver, 134 resource managers, 301 resource synchronization context NET, 397–399 overview, 396 UI, 400 ResourceManager class, 842 resources, services and, 393–396 response services, 504 ResponseContext class, 507, 846 root transaction scope, 334 Index | 867 Download from Library of Wow! eBook S Safe controls, 844 SafeLabel class, 404 scalability, 10X golden rule, 177 scope, 730 SecureClientBase class, 847 SecureDuplexClientBase class, 847 security, 535 (see also intranet application scenario) anonymous application scenario, 591–593 authentication, 525 authorization, 526 B2B application scenario, 585–591 callbacks and, 564, 593, 594 client-side, 605–612 coding standards, 834 federated, 28 host-side declarative, 604 identity management, 533 messages and, 24 no security scenario, 593–595 overall policy, 525, 534 queued services and, 486 scenario-driven approach, 534 SecurityBehavior attribute, 596–604 service bus, 657, 667 transfer security, 527–532 security audits, 612–616 security policy, 525, 534 security principal, 558 SecurityAccessDeniedException, 256 SecurityBehaviorAttribute class, 596–604, 847 SecurityCallFrame class, 854 SecurityCallStack class, 854 SecurityCallStackBehaviorAttribute class, 854 SecurityCallStackClientBase class, 854 SecurityCallStackContext class, 854 SecurityCallStackInterceptor class, 854 SecurityHelper class, 847 SecurityNegotiationException, 256 self-hosting base addresses, 16 choosing a host, 22 overview, 13–15 required for discovery, 724 required for relay service, 619 ServiceHost class, 18 singleton, 23 Visual Studio 2010, 16 SendOrPostCallback delegate, 400 Serializable attribute class hierarchy and, 124 concrete collections, 160 data contracts and, 116–123 functionality, 105 serialization class hierarchy and, 144 data contract events, 120 data contracts and, 103–110 enumerations, 154 NET, 105 service behaviors, 170 service bus and ACS (Access Control Service), 619, 657 adding default endpoints, 626 addresses, as a relay service, 619 authentication, 657–667 auto-start, 21 bindings, 27, 626–633 buffered services, 643–652 buffers versus queues, 635 buffers, working with, 636–642 connection modes, 628 connection payment plans, 620 creating a service namespace, 620 discovery, 752–764 Explorer, 625 ExtractNamespace() method, 623 Message security, 669 metadata over the, 665 overview, 617 programming the, 620 registry, 623 response service, 652–657 sending and receiving messages, 642 transfer security, 667–683 Transport security, 668 service bus security, 657, 667 service contract factoring, 91–94 service contracts callback hierarchy, 246 callback operations, 231 client-side hierarchy, 87–90 coding standards, 827 collections and, 160 contract queries, 95–101 868 | Index Download from Library of Wow! eBook defined, factoring and design, 90–94 importing, 157 inheritance, 86–90 operation overloading, 83–85 operations, 225 service synchronization context forms as services, 412–415 hosting in UI thread, 406–412 overview, 405 parallel task library, 403 priority processing, 425–428 thread affinity, 423 thread pool synchronizer, 418–423 UI threads, 415 Service transaction mode, 321, 324, 376 service transactional callbacks, 379 service-orientation (SO) background, 691 component-orientation, 688–693 defined, history, 685 object-orientation, 687 tenets/principles, 694–696 what’s next, 696–699 service-oriented applications, 2, 693 Service/Callback transaction mode, 376 ServiceBehavior attribute ConcurrencyMode property, 237, 350, 384 functionality, 170 IgnoreExtensionDataObject property, 153 IncludeExceptionDetailInFaults property, 268 InstanceContextMode property, 170, 172, 178, 186 ReleaseServiceInstanceOnTransactionCom plete property, 348–355, 360, 371, 372 TransactionAutoCompleteOnSessionClose property, 358 TransactionIsolationLevel property, 329 TransactionTimeout property, 330 UseSynchronizationContext property, 406 ServiceBufferResponseBase class, 655, 849 ServiceBusAnnouncementSink class, 769– 772, 848 ServiceBusClientBase class, 681, 848 ServiceBusDiscoveryClient class, 760–764, 848 ServiceBusDiscoveryFactory class, 764, 848 ServiceBusDiscoveryHelper class, 764, 848 ServiceBusDualClientBase class, 683 ServiceBusDuplexClientBase class, 848 ServiceBusEventsClientBase class, 853 ServiceBusEventsHost class, 853 ServiceBusHelper SetServiceBusCredentials() method, 666 ServiceBusHelper class, 847 AddServiceBusDefaultEndpoints() method, 626 ConfigureBinding() method, 680, 681 ConfigureMessageSecurity() method, 680 CreateBuffer() method, 640 DeleteBuffer() method, 640 PurgeBuffer() method, 640 SetBehavior() methods, 661 SetServiceBusCredentials() methods, 660, 662 VerifyBuffer() method, 640 ServiceBusHost class, 848 ConfigureAnonymousSecurity() method, 678 ServiceBusMetadataHelper class, 666, 850 ServiceContract attribute callback operations, 243 CallbackContract property, 231 contract queries, 100 functionality, 8, 83 inheritance, 86 Name property, 11 SessionMode property, 178, 179 ServiceDescription class, 220 ServiceEndpoint class channel support, 71 Contract property, 96 endpoint support, 96 ServiceHost class Abort() method, 18 AddDefaultEndpoints() method, 38 AddServiceEndpoint() method, 34, 46 Close() method, 14 endpoint configuration, 34 ICommunicationObject interface, 17, 18 Main() method, 14 Open() method, 14 self-hosting, 14–15 Index | 869 Download from Library of Wow! eBook SetThreadAffinity() method, 424 Singleton property, 189 SingletonInstance property, 188, 189 ServiceHost class, 838 AddAllMexEndPoints() method, 47, 49 AddErrorHandler() method, 287, 288 EnableMetadataExchange() method, 47 exception diagnostics, 270 functionality, 18 and generic resolvers, 139 HasMexEndpoint property, 47, 49 MEX endpoints, 47 queuing, 466 ServiceThrottle property, 224 SetThreadAffinity() method, 424 streamlining, 189 ServiceHostBase class AddDefaultEndpoints() method, 626 ChannelDispatchers property, 223, 283 CloseTimeout property, 15 Description property, 40, 220 ServiceHostFactory class, 20 main() method, 20 ServiceInterceptorBehaviorAttribute class, 853 ServiceKnownType attribute applying multiple times, 128 functionality, 126 interfaces and, 141 ServiceMetadataBehavior class, 42 ServiceModelEx library, xxii–854, 837 ServiceRegistrySettings class, 624 ServiceResponseBase class, 512–514, 513, 846 ServiceSecurity class, 847 ServiceSecurity enum, 680 ServiceThrottleHelper class, 222, 839 ServiceThrottlingBehavior class, 221 session ID, 184, 185 sessionful services (see per-session services) sessiongram, 477 SessionMode enumeration Allowed value, 179 NotAllowed value, 181 queued services, 477–484 queued sessionful services, 482 Required value, 180, 181, 191, 358 transport sessions, 179 shared data contracts, 123 shared secret authentication, 659–663 single-phase commit protocol, 301 singleton services auto-start, 21 choosing, 189 concurrency management, 393 configuring, 185 connection management, 240 defined, 169, 185 initializing, 187 instance management, 169, 185–189, 371– 374 queued, 483 stateful, 372 subscribers, 792 SOAP faults, 261 SoapFormatter class, 106 soft impersonation, 564 SQL Server (Microsoft) LogbookManager service, 281 persistence provider, 216 promoting transactions, 310 SqlPersistenceProvider class, 216 SqlPersistenceProviderFactory class, 216 state identifier, 345 state objects, 449 state-aware services, 174, 354 static addresses, 725 Stream class formatters and, 107 functionality, 251, 252 TransferMode property, 252 streaming and binding, 252 messages, 251 transport and, 253 streaming transfer mode, 251 StreamingContext structure, 120 streams, 105 subclasses base classes and, 124 hierarchy in, 123 serialization order, 144 subscriber defined, 247 subscriber service background, 775 design pattern, 776 event management, 247–251 framework, 777–808 870 | Index Download from Library of Wow! eBook subscriber types, 777 subscribers, 632 SubscriptionManager class, 778, 852 svc files Factory tag, 19 IIS hosting, 12 WAS hosting, 19 SvcConfigEditor file editor, 60, 66 SvcUtil utility client config file, 59 generating proxies, 56–57 importing data contracts, 113 XML serialization, 117 synchronization automatic, 383 manual, 383 synchronization context affinitySynchronizer, 423 callbacks and, 431–439 defined, 397 prioritySynchronizer, 426 resource, 396–405 service, 405–428 SynchronizationContext class, 397 ThreadPoolSynchronizer class, 418–423 WindowsFormsSynchronizationContext class, 400 working with, 398 SynchronizationContext class, 397 Syndication Service Library project, 67 System.Messaging, 636, 643 System.Runtime.Serialization namespace, 107, 111, 120 System.ServiceModel namespace, System.ServiceModel.Channels namespace, 491 System.ServiceModel.Description namespace, 42, 95 System.ServiceModel.Persistence namespace, 216 System.Threading namespace, 397 System.Transactions namespace, 311, 328, 331 System.WorkflowServices assembly, 216 T TCP addresses, binding support, 25, 306 MEX endpoints, 43 relay binding support, 626–630, 670–675 transaction-aware bindings, 301 transport transfer security, 528 thread affinity callbacks and, 431, 438 defined, 396 HostThreadAffinity, 425 service synchronization context, 423 ThreadPoolSynchronizer class, 418–423 UI synchronization context, 400, 415 thread local storage (TLS), 312, 396 ThreadAbortException, 255 ThreadAffinityBehaviorAttribute class, 423, 845 ThreadPoolBehaviorAttribute class, 419–423, 437, 845 ThreadPoolHelper class, 845 ApplyDispatchBehavior() method, 422 CloseThreads() method, 422, 423 GetSynchronizer() method, 422 HasSynchronizer() method, 422 ThreadPoolSynchronizer class, 418–423, 435, 845 threads callback operations, 237 host process and, 15 UI, 406–412, 415 ThreadStatic attribute, 409 throttling administrative, 220 configuring, 219–224 functionality, 217 programmatic, 220 queued services and, 485 reading values, 222 service consumption parameters, 218 time to live, 487, 635 TimeoutException asynchronous calls, 456 call timeouts, 63 concurrency management, 385 error masking, 256 request-reply operations, 225 throttling, 218 timeouts asynchronous calls and, 456 call, 63 queued services, 486 Index | 871 Download from Library of Wow! eBook transaction, 329, 331 TransactionScope class, 339 TLS (thread local storage), 312, 396 Transaction class ambient transactions, 312 Current property, 312, 332 defined, 311 Rollback() method, 311 TransactionInformation property, 312 transaction flow bindings and, 301–304, 316–324 Client mode, 320 Client/Service mode, 318–320 None mode, 322 Service mode, 321, 324, 376 timeout and, 331 transaction management, 333–340 transaction management challenges, 298 distributed transactions, 299 overview, 297 single-phase commit protocol, 301 transaction flows, 333–340 two-phase commit protocol, 300, 324 transaction managers defined, 299 DTC, 308, 313 KTM, 308 LTM, 308 overview, 307 promoting transactions, 310, 311 transaction modes Callback mode, 376 callbacks, 376 choosing, 324 Client mode, 320 Client/Service mode, 317–320, 376 None mode, 322, 376 overview, 316, 317 Service mode, 321, 324 Service/Callback mode, 376 transaction propagation modes supported, 316–324 one-way calls, 304 transaction flow and bindings, 301, 302 transaction flow and operation contract, 302–304 transaction properties ACID properties, 295 atomic property, 295 consistent property, 296 durable property, 296 isolated property, 296 transaction protocols bindings, 306 options supported, 305 transaction-aware bindings, 301, 302, 318 TransactionAbortedException, 325, 326 transactional files system (TxF), 308 transactional programming ambient transactions, 314 non-service clients, 340 resource requirements, 295 transaction flow management, 333–340 transaction isolation, 327 transaction propagation modes, 316–324 transaction timeouts, 329, 331 TransactionalBehavior attribute and, 369 TransactionScope class, 331 voting and completion, 324–327 transactional registry (TxR), 308 transactional resources auto-enlisting resources, 295 enlisting resources, 295 overview, 295 Transactional class, 344, 355, 843 TransactionalArray class, 344, 355, 843 TransactionalBehaviorAttribute class, 844 default values and, 367 functionality, 366 transactional programming and, 369 TransactionRequiredAllOperations property, 367 TransactionalCollection class, 843 TransactionalDictionary class, 365 TransactionalDictionary class, 344, 843 TransactionalInstanceProvider class, 841 TransactionalInstanceProviderFactory class, 366, 367, 841 TransactionalInstanceStore class, 841 TransactionalLinkedList class, 843 TransactionalList class, 344, 843 TransactionalLock class, 842 TransactionalMemoryProvider class, 840 TransactionalMemoryProviderFactory class, 365, 367, 840 TransactionalMemoryStore class, 840 TransactionalQueue class, 843 872 | Index Download from Library of Wow! eBook TransactionalSortedDictionary class, 843 TransactionalSortedList class, 843 TransactionalStack class, 843 TransactionFlow attribute callback contracts, 375 Client transaction mode, 320 Client/Service transaction mode, 318 None transaction mode, 322 operation contracts, 302–304 Service transaction mode, 321 TransactionFlowOption attribute Allowed value, 304, 315, 317, 318, 319 Mandatory value, 304, 320 NotAllowed value, 303, 305, 321, 322 TransactionInformation class, 312, 313 TransactionOptions structure, 340 TransactionProtocol class, 306 transactions aborted, 294, 323 ambient, 312, 314 asynchronous calls and, 457 boundaries, 343 callback operations, 376–381 coding standards, 831 committed, 294, 324 concurrent, 356 defined, 294 distributed, 299 in-doubt, 294 instance management, 343–374 local versus distributed, 312–313 promoting, 310, 311 queued services, 471–477, 514–517 recovery challenge, 293 reliability and, 302 service state management, 342 terminating, 327 timeouts, 329, 331 TransactionScope class functionality, 331 isolation level, 340 timeouts, 339, 340 TransactionScopeOption enumeration Required value, 335, 336 RequiresNew value, 335, 338 Suppress value, 336, 338 transfer security, 527–532 transfer security, service bus, 667–683 one-way relay binding and, 676 streamlining, 678–683 TCP relay binding and, 670–675 WS relay binding and, 676 transient subscribers, 777 transport reliability, 77 transport schemes bindings and, 26 defined, HTTP addresses, IPC addresses, messages and, 24 MEX endpoints, 43 MSMQ addresses, TCP addresses, WCF support, transport sessions, 383 (see also concurrency management) bindings and, 76 defined, 75 exceptions and, 229 per-call services and, 173 private-session mode, 177 SessionMode enumeration, 179 streaming and, 253 terminating, 76 TransportClientCredentialType enum, 658, 663 TransportClientEndpointBehavior class, 658 two-phase commit protocol defined, 300 voting, 324 TxF (transactional files system), 308 TxR (transactional registry), 308 U UDP (User Datagram Protocol), 723 UI synchronization context callbacks and, 431–435 concurrency management, 433 hosting UI thread, 406–412 overview, 400–405 UI thread concurrency management, 415, 433 hosting on, 406–412 multiple, 410 unknown faults, 266 User Datagram Protocol (UDP), 723 using statement Index | 873 Download from Library of Wow! eBook closing proxies, 62, 259 ending transactions, 332 V versioning, 146–153 versioning round-trip, 151–153 Visual Studio 2010 Add Service Reference option, 53 asynchronous proxies, 440 client config file, 59 Configure Service Reference dialog, 54 generating proxies, 53–54 IIS-hosted services, 12 importing data contracts, 113, 114 self-hosting, 16 service references, 123 shortcomings of, 579 test client, 64–67 WCF-provided host, 50 WcfTestClient support, 66 volatile resource managers (see VRMs) voting callback operations and, 378 committing changes, 300, 324–327 declarative, 324 explicit, 326 nested scopes and, 336 TransactionScope class and, 332 VRMs (volatile resource managers) durable property, 297 MemoryProviderFactory class, 365 Transactional class, 344, 355 TransactionalArray class, 355 TransactionalBehavior attribute, 366 TransactionalDictionary class, 365 TransactionalDictionary class, 344 TransactionalMemoryProviderFactory class, 365, 367 W WAS (Windows Activation Service) custom hosting, 19 hosting, 12, 471 WCF (Windows Communication Foundation), 1, 67 Visual Studio 2010, 50 Windows Server AppFabric, 20 WCF coding standard concurrency management, 832 data contracts, 827 design guidelines, 825 essentials, 826 faults, 830 instance management, 828 operations and calls, 828 queued services, 833 security, 834 service contracts, 827 transactions, 831 WCF formatters, 107–109, 128 WCF Service Libraries, 67 WcfSvcHost utility, 50 WcfTestClient.exe (test client), 64–67 WcfWrapper, 371 WcfWrapper class, 74 WcfWrapper class, 838 Web services, binding support, 25 web.config file, 13 WebHttp Binding class functionality, 29 WebHttpBinding syndicated endpoints, 67 WebHttpRelayBinding class, 633 WF (Workflow) Windows Server AppFabric, 20 Windows Activation Service (see WAS) Windows Azure AppFabric Service Bus addresses, Windows Azure AppFabric Service Bus (see service bus) Windows Communication Foundation (WCF), 1, 67 Windows role localization, 564 Windows Server AppFabric overview, 20 WindowsFormsSynchronizationContext class, 400 WindowsIdentity class, 548, 550 WS bindings, 301, 676 WS-Security, 24 WS2007FederationHttpBinding class, 28, 307 WS2007HttpBinding class, 28, 307 WS2007HttpRelayBinding class, 630 WSAT (WS-Atomic Transaction), 24, 306 WsdlImporter class, 96 WSDualHttpBinding class, 28, 230, 307 WSFederationHttpBinding class, 28, 307 874 | Index Download from Library of Wow! eBook WSHttpBinding class call timeout, 63 derivations, 28 functionality, 25 per-session services, 179 reliability and, 78, 302 transaction protocols and, 307 transfer security, 533 transport schemes, 26 WSHttpContextBinding class, 27 X X509 certificate, 526, 532 X509Identity, 547 XML serialization, 117 XmlSerializerFormat attribute, 117 Index | 875 Download from Library of Wow! eBook Download from Library of Wow! eBook About the Author Juval Löwy is a software architect and the principal of IDesign, specializing in NET architecture consulting and advanced training Juval is Microsoft’s Regional Director for the Silicon Valley, working with Microsoft on helping the industry adopt NET 4.0 He participates in the Microsoft internal design reviews for future versions of NET and related technologies Juval has published numerous articles, regarding almost every aspect of NET development, and he is a frequent presenter at development conferences Microsoft recognized Juval as a Software Legend, one of the world’s top NET experts and industry leaders Colophon The animal on the cover of Programming WCF Services, Third Edition, is an angelfish (genus Pterophyllum) Angelfish are found in tropical and subtropical reefs around the world; there are at least 86 different species The average angelfish is about to 12 inches (20 to 30 cm) long, but their size varies greatly, as does their coloring, which changes with maturity The diet of angelfish consists of algae, worms, and various shellfish and small sea creatures A spine on the gill cover differentiates the angelfish from the also-colorful butterfly fish Depending on the species, angelfish have different mating habits Some mate for life in territorial pairs, while others create harems of female fish with one dominant male All angelfish are protogynous hermaphrodites, which means that if the dominant male dies or leaves the group, a female morphs into a male for mating purposes In some countries angelfish are used for food, but mostly they are caught for aquariums Rare species of angelfish can range in price from hundreds to thousands of dollars In addition to collectors, reef destruction and continual environmental degradation threaten angelfish The cover image is from Wood’s Reptiles, Fishes, Insects, &c The cover font is Adobe ITC Garamond The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont’s TheSansMonoCondensed Download from Library of Wow! eBook Download from Library of Wow! eBook ... 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. .. Programming WCF Services Download from Library of Wow! eBook Download from Library of Wow! eBook THIRD EDITION Programming WCF Services Juval... 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 Download from

Ngày đăng: 21/03/2019, 09:24

Mục lục

    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

    WCF and Location Transparency

    Applying the ServiceContract attribute

    Self-hosting and base addresses

    The ServiceHost<T> class

    Custom Hosting in IIS/WAS

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

Tài liệu liên quan