MSDN Magazine - February 2008 - (Page 93) H u g h A n g a n d D a v i d S a n F i l i p p o PIAB Integrating The Policy Injection Application Block With WCF Services ne of the most important software design principles is the separation of different responsibilities within our applications. In service-oriented design, we separate applications into services and operations. In real life, however, implementation concerns tend to leak into the services. This is a problem not only in service-oriented design, but in object-oriented design as well. Enterprise Library 3.0 introduced the Policy Injection Application Block (PIAB) to solve this problem in object-oriented design. At the time of this writing, however, the latest version of Enterprise Library (3.1) doesn’t directly support the integration of PIAB with Windows® Communication Foundation (WCF) services, so using PIAB to separate concerns in service-oriented applications might seem daunting. But, as you’ll see, it’s easy enough with the right techniques. Let’s get started. To leverage the PIAB, you must have control over how your objects are instantiated. With service frameworks like WCF that abstract object instantiation away from the developer, this creates a problem when trying to integrate the PIAB. However, WCF provides a variety of extensibility points through behaviors. Here we will show you how to leverage custom WCF behaviors in order to apply PIAB at the WCF service point without requiring additional code. With WCF service successfully integrated, PIAB can truly become a ubiquitous framework for separating service logic from cross-cutting implementation details. AND WCF A Real-World Example To better understand this leakage problem, imagine you were building a simple service to find a custom customer object using a customer ID. You write a simple method in Visual Studio® 2005 to invoke a data access object and return a customer object: public Customer GetCustomer(string customerID) { return CustomerDAO.GetCustomer(customerID); } This article uses the following technologies: WCF, PIAB This article discusses: Integrating the Policy Injection Application Block and WCF Creating Custom WCF Behaviors ✥ Applying behaviors using .NET attributes or configuration ✥ Integration without changing any code ✥ ✥ Code download available at: msdn.microsoft.com/msdnmag/code08.aspx Hugh Ang is a Senior Solution Architect at Avanade and is working as VP of Application Development for a client, overseeing its enterprise architecture as well as managing the application development department. You can read his blog at tigerang.blogspot.com. David San Filippo is a Solutions Developer at Avanade and holds MCPD Enterprise Application Developer, MCSD.Net, and MCDBA credentials. You can read his blog at www.mtelligent.com. february2008 93 http://msdn.microsoft.com/msdnmag/code08.aspx http://tigerang.blogspot.com http://www.mtelligent.com http://www.mtelligent.com
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.