Skip to Main Content
Programming WCF Services
book

Programming WCF Services

by Juval Lowy
February 2007
Intermediate to advanced content levelIntermediate to advanced
634 pages
16h 1m
English
O'Reilly Media, Inc.
Content preview from Programming WCF Services

Behaviors

By and large, the service instance mode is strictly a service-side implementation detail that should not manifest itself on the client side in any way. To support that and a few other local service-side aspects, WCF defines the notion of behaviors. A behavior is a local attribute of a service that does not affect its communication patterns. Clients should be unaware of behaviors, and behaviors do not manifest themselves in the service’s binding or published metadata. WCF defines two types of service-side behaviors governed by two corresponding attributes: the ServiceBehaviorAttribute is used to configure service behaviors; that is, behaviors that affect all endpoints (all contracts and operations) of the service. The ServiceBehavior attribute is applied directly on the service implementation class. In the context of this chapter, the ServiceBehavior attribute is used to configure the service instance mode. As shown in Example 4-1, the attribute defines the InstanceContextMode property of the enum type InstanceContextMode. The value of the InstanceContextMode enum controls which instance mode is used for the service.

Example 4-1. The ServiceBehaviorAttribute used to configure instance context mode

public enum InstanceContextMode
{
   PerCall,
   PerSession,
   Single
}
[AttributeUsage(AttributeTargets.Class)]
public sealed class ServiceBehaviorAttribute : Attribute,...
{
   public InstanceContextMode InstanceContextMode
   {get;set;}
   //More members
}

The OperationBehaviorAttribute is used ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming WCF Services, 3rd Edition

Programming WCF Services, 3rd Edition

Juval Lowy
Mastering ASP.NET Web API

Mastering ASP.NET Web API

Mithun Pattankar, Malendra Hurbuns

Publisher Resources

ISBN: 0596526997Supplemental ContentErrata Page