Tuesday, June 28, 2011

WCF Extensibility Resources

A great article in a old MSDN magazine explaining the most common extensibility points in WCF.

Extending WCF with custom behaviors

Overview:
There are essentially 5 common points of extensibility in a WCF service (and the corresponding interface to use):
  1. Message inspection (IDispatchMessageInspector)
  2. Operation selector (IDispatchOperationSelector)
  3. Message formatter (deserialisation) (IDispatchMessageFormatter)
  4. Parameter Inspection (IParameterInspector)
  5. Operation Invoker (IOperationInvoker)
These extender classes are injected into WCF using Behaviors. Options are:
Ensure any implementation of these interfaces also inherits Attribute to allow direct decoration of a contract/operation within code.

Wiring is best done with config or attribute use:
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<consoleMessageTracing/>
</behavior>
</serviceBehaviors>
</behaviors>
[ServiceContract]
public interface IZipCodeService
{
[ZipCodeCaching]
[ZipCodeValidation]
[OperationContract]
string Lookup(string zipcode);
}

No comments:

Post a Comment