Applying WebInvoke without an Attribute
Haven't posted in a long time but thought I'd post this bit of WCF extensibility I was working on at home. There is nothing on the Internet about how to do this & I felt I should figure something out. Scenario: You have legacy WCF services that you want to switch to a WebHttpBinding w/ JSON but don't want to update 1,337 service contracts to include a WebInvoke attribute, UriTemplates and Request/Response Body Types In this scenario I'll be assuming use of IIS and Windows Process Activation Services to host your service. The WebInvokeAttribute implements IOperationBehavior. So what we need to do is somewhere in the WCF stack apply this operation behavior programmatically to our Endpoint's Contract.Operations. Let's start from the bottom up & take a look at an extension method that does this. /// <summary> /// Automatically applies the Web Invoke behavior to all operations in the collection /// </summary> /// <param name="operatio...