Download presentation
Presentation is loading. Please wait.
Published byMeghan Hutchinson Modified over 9 years ago
1
Satisfy Your Technical Curiosity Beyond ABC: WCF practices from the field Christian Weyer thinktecture Co-Founder & Solution Architect http://www.thinktecture.com/staff/christian christian.weyer@thinktecture.com
2
Satisfy Your Technical Curiosity Beyond ABC: WCF practices from the field Christian Weyer thinktecture Co-Founder & Solution Architect http://www.thinktecture.com/staff/christian christian.weyer@thinktecture.com
3
Satisfy Your Technical Curiosity What To Expect ABC 101 – still ABC 101 – still WCF Internals 101 ContractBindingSerializationHostingConsuming State Management SecurityFaultsMonitoring
4
Satisfy Your Technical Curiosity ABC 101
5
Satisfy Your Technical Curiosity Client Service WCF: Bird’s Eye View Endpoint
6
Satisfy Your Technical Curiosity WCF: Address, Binding, Contract Service CBA CBA Client A BC Address Where? Contract What? Binding How? Endpoint CBA
7
Satisfy Your Technical Curiosity Internals 101
8
Satisfy Your Technical Curiosity Client Code parameters Client Runtime Channel Transport Channel byte[] Encoder Service Type parameters Dispatcher Runtime Channel Transport Channel byte[] Encoder Message Inspector Custom Channel Custom Transport Custom Encoder Custom Transport Custom Channel Message Inspector Operation Selector Parameter Inspector Operation Invoker Message Formatter Parameter Inspector Message Formatter * Added by configuring the runtime with behaviors * Added by adding binding elements to the binding Contract WSDL Exporter Contract WSDL Importer Channel Layer Service Model Layer
9
Satisfy Your Technical Curiosity Layered Extensibility Protocol Channel(s) Transport Channel Service Model Extensibility (local only) Channel Extensibility (affects the wire) Protocol Channel(s) Transport Channel Client Runtime Dispatch Runtime
10
Satisfy Your Technical Curiosity Beyond ICalculator
11
Satisfy Your Technical Curiosity ‚Distributed‘ Hot Spots Overall architecture, service orientation WCF contract design WCF bindings WCF without sessions WCF duplex and callbacks WCF streaming WCF hosting WCF proxy handling Client threading Data access & notification
12
Satisfy Your Technical Curiosity More ‚Distributed‘ Hot Spots WF custom activities WF persistence, tracking, workflow monitoring WF and WCF integration Unit and Load Testing Debugging Tracing & Logging
13
Satisfy Your Technical Curiosity Contract Modeling Message Exchange Pattern (MEP) One-Way, Request-Reply, Notifications, Duplex Data Serialization rules Faults Messages Implicit or explicit Try thinking decoupled
14
Satisfy Your Technical Curiosity Contract Modeling Set Name, Namespace, Action, ReplyAction Also on ServiceBehavior and binding POX/REST-style contract with Message type Addressable from any HTTP-enabled code Improved in Orcas Interop with Java still a stretch Basic stuff works Try to flatten WSDL and XSDs Vast interop needs to be proven
15
Satisfy Your Technical Curiosity Binding Selection „Choose whatever binding with whatever contract“ is not true Almost all out-of-the-box bindings are pretty much useless in real world Change their settings Creating custom bindings Custom bindings make up your day Improve configurability with user-defined binding and custom config Usually, you need one transport
16
Satisfy Your Technical Curiosity Binding Selection Binary encoding over HTTP in self-host looks like a winner in many scenarios Always perf and load test for your scenario; no ‚guessing‘ Quotas do not get communicated to clients Build custom message encoder, e.g. for emitting raw data
17
Satisfy Your Technical Curiosity Serialization WCF supports two serializers out-of-the-box DataContractSerializer (DCS) XmlSerializer (XS) DCS is new in.NET 3.0 and optimized for WCF‘s world Supports a large list of serialization mechanisms We can use e.g. NetDataContractSerializer to support object graphs and type information We can create our own serializer and hook it in In a lot of cases we need to revert back to XS for schema-based contract-first (Web) services modelling or for improved interop
18
Satisfy Your Technical Curiosity Hosting Please, use console applications only for testing Hosting in NT Service is straight-forward Leverages Windows SCM features Think about exception handling and logging WCF services should run as non-admin HTTP.sys must be configured IIS is robust, mature and scales IIS hosting has some overhead due to additional layering Streaming from inside IIS seems to have some problems Windows Process Activation Service (WAS) brings non-HTTP transports into the IIS picture Only on Windows Vista and Longhorn Server Same caveats still apply
19
Satisfy Your Technical Curiosity Consuming WCF offers svcutil.exe and/or ‚Add Service Reference…‘ in Visual Studio to generate proxy code and config svcutil.exe provides countless options but is a bit buggy ChannelFactory is a nice WCF class to leverage Use custom code generation tools to create your own ChannelFactory or ClientBase based client code Beware of ICommunicationObject-specific traps Open(), Close(), Abort() and cleanup cycle Always catch the ‚correct‘ exceptions Think about caching the ChannelFactory – it is very expensive to create
20
Satisfy Your Technical Curiosity State Management There is no ‚stateless‘ at all Our applications deal with… well: data – and data is state Define what data needs to be accessible when and where Enforce mode e.g. through sessionless contracts [ServiceContract(SessionMode= SessionMode.NotAllowed)] Beware of sessions semantics netTcp and namedPipes have implicit channel-based session semantics; as well as wsHttpBinding Try to avoid session affinity for scalability and robustness reasons Of course there are cases for using sessions
21
Satisfy Your Technical Curiosity Security „Secure, Reliable, Transacted!“ – yawn. Fact is that WCF really has almost any support for security-related scenarios we can imagine It is just quite tedious in v1 to set it up If you do not need interop and do not need federation always try to think transport security first It is mature, it is integrated, it is fast Custom bindings can be used to enable and setup security in a controlled way Security interop is still a ‚miracle‘
22
Satisfy Your Technical Curiosity Faults SO says that no exceptions should leave the service So far for the theory WCF can transmit exception details inside of a generic fault message Enable through ServiceBehavior Know about the implications Global IErrorHandler implementation can make error and fault handling even more robust XmlSerializer can not deal with fault information
23
Satisfy Your Technical Curiosity Monitoring WCF has vast features for tracing, logging and monitoring WMI Performance Counters Message Logging ‚Activity‘ Tracing Hook up your own tracing SvcTraceViewer tool looks complicated but is very useful for diagnosing MOM pack as SDK sample available
24
Satisfy Your Technical Curiosity Real-World Check WCF is here and WCF rocks But is still it is a v1 We are currently moving from collecting ‚practices‘ to ‚best practices‘ – slowly Guidance beyond Hello World and ICalculator If something is not here we can hook up our own implementation Not always is WCF the hammer, as not always everything is a nail
25
Satisfy Your Technical Curiosity Sample Application: YAPOS ? Yet Another Purchase Order Scenario? No, don’t fear. Let’s bring some coolness into our dev life – talk about developer videos and media Every ‘good’ developer these days needs to deal with online resources and multimedia content MSDN.TV Channel 9 Dotnetpro.tv (German)
26
Satisfy Your Technical Curiosity Sample Application Scenario Media Service Reviewer User Upload Service Message Queue Message Queue Web Server New Media Service
27
Satisfy Your Technical Curiosity
28
Resources Email Christian Weyer christian.weyer@thinktecture.com Weblog Christian Weyer http://blogs.thinktecture.com/cweyer thinktecture http://www.thinktecture.com
29
Satisfy Your Technical Curiosity
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.