Extending WCF with custom behaviors
Overview:
There are essentially 5 common points of extensibility in a WCF service (and the corresponding interface to use):
- Message inspection (IDispatchMessageInspector)
- Operation selector (IDispatchOperationSelector)
- Message formatter (deserialisation) (IDispatchMessageFormatter)
- Parameter Inspection (IParameterInspector)
- Operation Invoker (IOperationInvoker)
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