WCF Extensibility

Over the next months I intend on writing a series of posts about the (many) extensibility points from WCF (up to .NET Framework 4.0). The cadence should be around one new post every 1-2 weeks (depending on the workload I have at work).

WCF is a very powerful framework for creating distributed, service-oriented applications, and if you want to stick to defining a few operations, exposing them to a service over one of the pre-defined bindings, and consuming them in a client, you can look at any of the many “hello world” examples out there and that will be enough. However, if you want to do something a little differently, almost everything (as I’ve found out while answering to questions on the WCF MSDN Forum and other sources of user complaint feedback) can be accomplished using one of the extensibility points in WCF.

The biggest problem is which one. There are over 30 different points in which one can hook up code in the whole WCF pipeline (including serialization and the service model) that most people simply get too confused about which one is the right for their specific scenario (and sometimes a solution actually needs code in more than one of those places to work together). I’ve worked with WCF for over 6 years now (since before it was released), and I still don’t know all of them (and this series will be a good motivation for me to learn more about the product I work on).

In each post, I’ll talk about one of the extensibility points. My plan is to present some scenarios in which it can help, and always have code samples for them. Whenever applicable, I’ll talk about different ways of accessing that extensibility point, and some tips about the specific hook which may not be present in the “official” MSDN documentation.

Here’s a list of topics I plan on writing about. It won’t be necessarily done in this order (I’ll likely write about the most used ones first, or one for which I’ve seen an issue at that week), and I may add more items to this index if I find (or remember) any more.

1. Service model extensibility
    1.1. Behaviors
        1.1.1. IServiceBehavior
        1.1.2. IContractBehavior
        1.1.3. IEndpointBehavior
        1.1.4. IOperationBehavior
    1.2. WCF Runtime
        1.2.1. Message interception
            1.2.1.1. I[Client/Dispatch]MessageInspector
            1.2.1.2. IParameterInspector
        1.2.2. Mapping between message and operation parameter
            1.2.2.1. I[Client/Dispatch]MessageFormatter
        1.2.3. Mapping between message and CLR operations
            1.2.3.1. I[Client/Dispatch]OperationSelector
            1.2.3.2. IOperationInvoker 
        1.2.4. Instance [context] creation / initialization
            1.2.4.1. IInstanceProvider
            1.2.4.2. IInstanceContextProvider 
        1.2.5. Error handling
            1.2.5.1. IErrorHandler
        1.2.6. Others
            1.2.6.1. Initializer interfaces (IInstanceContextInitializer / IChannelInitializer / ICallContextInitializer)
            1.2.6.2. IInteractiveChannelInitializer
    1.3. Exposing / consuming metadata
        1.3.1. IWsdlExportExtension
        1.3.2. IWsdlImportExtension (and IOperationContractGenerationExtension / IServiceContractGenerationExtension)
        1.3.3. IPolicy[Import/Export]Extension
    1.4. Configuration
        1.4.1. BehaviorExtensionElement
        1.4.2. BindingElementExtensionElement  / StandardBindingElement / StandardBindingCollectionElement
    1.5. Web Hosting
        1.5.1. ServiceHostFactory
    1.6. WCF REST (3.5 / 4.0 model)
        1.6.1. QueryStringConverter
        1.6.2. Extending WebHttpBehavior 
    1.7. Others
        1.7.1. Extensible objects: IExtensibleObject<T> and IExtension<T>
2. Channel extensibility 
    2.1. Protocol channels (client)
    2.2. Protocol channels (server)
    2.3. Message encoders
    2.4. Transport channels
        2.4.1. Request transport channels - part 1 (synchronous path)
        2.4.2. Request transport channels - part 2 (interaction with runtime extensions)
        2.4.3. Request transport channels - part 3 (asynchronous path)
        2.4.4. Reply transport channels
        2.4.5. Duplex transport channels
3. Serialization extensibility
    3.1. Serialization callbacks (On[Ser/Deser]ializ[ing/ed])
    3.2. IDataContractSurrogate
    3.3. DataContractResolver
    3.4. IExtensibleDataObject / IDeserializationCallback / IObjectReference
4. Miscellaneous extensibility scenarios 
    4.1. Hooking into the tracing mechanism
    4.2. Custom serialization in Silverlight 4
    4.3. Extensibility in Windows Phone / Silverlight 3
    4.4. WCF RIA Services
5. Wrapping up

I hope you find this upcoming series interesting, and I’m looking forward to your feedback – I’ll bring them to the team to the best of my abilities.

By the way, the WCF team is aware that, although very powerful, the framework can sometimes be hard to use. One of the main focus of the upcoming release is exactly making it simpler to create / configure / consume WCF services.

时间: 2024-08-05 07:05:42

WCF Extensibility的相关文章

收藏2篇关于WCF异常处理的文章

WCF Extensibility – IErrorHandler Exception Handling in WCF Web Service收藏2篇关于WCF异常处理的文章,码迷,mamicode.com

Service Station - An Introduction To RESTful Services With WCF

Learning about REST An Abstract Example Why Should You Care about REST? WCF and REST WebGetAttribute and WebInvokeAttribute UriTemplate and UriTemplateTable WebHttpBinding and WebHttpBehavior WebServiceHost and WebServiceHostFactory Using the Example

Service Discovery in WCF 4.0 – Part 2 z

Service Discovery in WCF 4.0 – Part 2 In the previous post I discussed about the basic usage of WCF Discovery in 4.0. I implemented a managed discovery service by inheriting from System.ServiceModel.Discovery.DiscoveryProxy. I utilized a concurrent d

WCF WS-Security and WSE Nonce Authentication【转】

原文:http://weblog.west-wind.com/posts/2012/Nov/24/WCF-WSSecurity-and-WSE-Nonce-Authentication?utm_source=tuicool&utm_medium=referral WCF makes it fairly easy to access WS-* Web Services, except when you run into a service format that it doesn't suppor

WCF学习系列一【WCF Interview Questions-Part 1 翻译系列】

http://www.topwcftutorials.net/2012/08/wcf-faqs-part1.html WCF Interview Questions – Part 1 This WCF Tutorial is a collection of most frequently asked interview questions about Windows Communication Foundation (WCF) covering the beginner to professio

WCF The service cannot be activated because it does not support ASP.NET compatibility

测试发布到虚拟目录中时发生的报错现象,由于不支持asp.net兼容性而导致服务无法激活启用. 具体错误信息如下: Server Error in '/Service2' Application. -------------------------------------------------------------------------------- The service cannot be activated because it does not support ASP.NET com

.NET4.5中WCF中默认生成的basicHttpsBinding的研究

起因: 使用.net4.5建立了一个空白的WCF服务.默认使用的绑定配置是basicHttpsBinding. 问题发现: 1.用客户端进行服务引用,生成了默认的配置文件,其中绑定配置是basicHttpBinding. 2.因为需要单次传递大批量数据,所以修改绑定配置,如下: <basicHttpBinding> <binding name="BasicHttpBinding_IService" closeTimeout="00:10:00" r

PHP调用WCF提供的方法

一.准备工作 1.安装wampserver:过程略 2.配置wampserver: 2.1打开php.ini文件,去掉 ;extension=php_soap.dll 这里那个分号. 也有说把这个 ;extension=php_openssl.dll前面的分号也去掉的. 2.2 如上图,将php_soap打上√. 2.3 如上图,打开httpd.conf文件,找到Listen 80 ,将80端口改成一个较大的端口,如8000.因为80端口也能别的程序用着. 在这个directory里面有php页

WCF服务部署到IIS7.5

下面介绍如何把WCF服务部署到IIS: 为WCF服务创建.svc文件 我们知道,每一个ASP.NET Web服务都具有一个.asmx文本文件,客户端通过访问.asmx文件实现对相应Web服务的调用.与之类似,每个WCF服务也具有一个对应的文本文 件,其文件扩展名为.svc.基于IIS的服务寄宿要求相应的WCF服务具有相应的.svc文件,.svc文件部署于IIS站点中,对WCF服务的调用体 现在对.svc文件的访问上. .svc文件的内容很简单,仅仅包含一个ServiceHost指令(Direct