I'm not sure I understand the difference between web.config elements <endpointBehaviors>
and <serviceBehaviors>
(and the adjoining behaviours, of course).
From here:
ServiceBehavior applies only on service while EndpointBehavior applies on both client and service.
ServiceBehavior can be specified via config/attribute/code while endpointbehavior can be specified via config/code.
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.
Also MSDN can always be referred to get the details:
<endpointBehaviors>
This configuration section represents all the behaviors defined for a specific endpoint.
<serviceBehaviors>
This configuration section represents all the behaviors defined for a specific service.
A good MSDN reference: Configuring and Extending the Runtime with Behaviors
Some usability differences are
ServiceBehavior applies only on service while EndpointBehavior applies on both client and service.
ServiceBehavior can be specified via config/attribute/code while endpointbehavior can be specified via config/code.
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 there is the biggest difference, if you want to customize endpoints on client then the only option is IEndpointBehavior.
The Contract specifies what the service actually does. In other words, what Operations are valid.
The Endpoint specifies an actual running instance of the service. It is the actual "service" in the sense that it executes, either as a Windows Service or under IIS.
The Service Behavior defines how the endpoint interacts with clients. Attributes like security, concurrency, caching, logging, etc. - those are all part of the behavior.
There is also an Operation Behavior which is similar to the Service Behavior but only gets applied when a specific operation is run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With