Friday, 9 January 2015

Introduction to BehaviorExtensionElement

BehaviorExtensionElement


WCF Behaviors are classes that affect runtime operation.

It comes in to the picture when WCF runtime(execution) starts on the client and server       and message flow starts in between the two.


Service Host:
Provides a host for services.

ServiceHost is responsible for defining the instancing and 
concurrency aspects of a server, in addition to dispatching messages to the 
proper operation.
a) When a message is received by a service and dispatched 
to a certain method of a class,
should ServiceHost  create a new instance 
of that class for each request or should it reuse instances?
b) And when 
ServiceHost  calls the method on that class, should it enlist in a transaction? 
Both of these are specified in behaviors and used during initialization.
There are three primary types of behaviors.
1) Service Behaviors
2) Endpoint Behaviors
3) Operation Behaviors
4) CallBack Behaviors
1) Service behaviors  run at the service level and have access to all of the endpoints. They control items such as instancing and transactions. Service behaviors are also available for authorization and auditing.
2) Endpoint behaviors are scoped to the service endpoint. These are well-suited for inspecting and taking actions on messages as they come in and out of service.
3) Operation behaviors are scoped at the operation level and are well-positioned for manipulating serialization, transaction flow, and parameter handling for a service operation.
4) CallBack Behaviors are similar to the Service Behaviors but control the Endpoints created in duplex communication.









No comments:

Post a Comment