The ApplyDispatchBehavior method on IServiceBehavior has access to all endpoints and their runtime components and so shouldn't that be enough for wiring up customization? The short answer is yes, but there are subtle differences.
Some usability differences are:
- ServiceBehavior applies only on a Service while EndpointBehavior applies on both client and service.
- ServiceBehavior can be specified via Attributes/Code/Config file while Endpointbehavior can be specified through Code or Config file.
- ServiceBehavior has access to all ServiceEndpoints dispatch runtime and so could modify all dispatch runtimes while EndpointBehavior gets called with the runtime for that endpoint only.
Look at it this way, ServiceBehavior lets you access runtime parameters for all endpoints while EndpointBehavior lets you access runtime components only for that endpoint. So if you have a need to extend functionality that spawns the entire contract (or multiple contracts) then use ServiceBehavior and if you are interested in extending one specific endpoint then use EndpointBehavior.
And of course, the biggest difference is if you want to customize endpoints on client/consumer then the only option is IEndpointBehavior.
2 comments:
Neat explanation... Thanks for Sharing
Thyagaraju Govardhan
This was very informative. I have been reading your blog a lot over the past few days and it has earned a place in my bookmarks.
Post a Comment