<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type='text/xsl' href='http://davidpallmann.spaces.live.com/mmm2008-05-17_13.22/rsspretty.aspx?rssquery=en-US;http%3a%2f%2fdavidpallmann.spaces.live.com%2fcategory%2fWCF%2ffeed.rss' version='1.0'?><rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:msn="http://schemas.microsoft.com/msn/spaces/2005/rss" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>David Pallmann's Blog: WCF</title><description /><link>http://davidpallmann.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&amp;_c=BlogPart&amp;partqs=catWCF</link><language>en-US</language><pubDate>Wed, 23 Jul 2008 11:36:44 GMT</pubDate><lastBuildDate>Wed, 23 Jul 2008 11:36:44 GMT</lastBuildDate><generator>Microsoft Spaces v1.1</generator><docs>http://www.rssboard.org/rss-specification</docs><ttl>60</ttl><cf:parentRSS>http://davidpallmann.spaces.live.com/blog/feed.rss</cf:parentRSS><live:type>blogcategory</live:type><live:identity><live:id>-1630591290702063730</live:id><live:alias>davidpallmann</live:alias></live:identity><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="typelabel" label="Type" /><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="tag" label="Tag" /><cf:group element="category" label="Category" /><cf:sort element="pubDate" label="Date" data-type="date" default="true" /><cf:sort element="title" label="Title" data-type="string" /><cf:sort ns="http://purl.org/rss/1.0/modules/slash/" element="comments" label="Comments" data-type="number" /></cf:listinfo><item><title>Service Pass-Through in Neuron ESB</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!445.entry</link><description>&lt;h1 style="margin:24pt 0in 0pt"&gt;&lt;font face=Cambria color="#365f91" size=5&gt;Service Pass-Through in Neuron ESB&lt;/font&gt;&lt;/h1&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;Today I’d like to talk about how you can connect your services (and clients) to pass message traffic through an ESB, rather than directly connecting to each other. We call this “service pass-through”. &lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Why Service Pass-Through?&lt;a href="http://byfiles.storage.live.com/y1pvhHyq8t_9gsPJ3EmoCgVzbiIX3DB4VrAhw0MnT9JqYGf8RrIgYP10A53iUdJxR8I8grj0t-gpHQ" target="_blank"&gt;&lt;/a&gt;&lt;/font&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;Before getting into &lt;u&gt;how&lt;/u&gt; this is done, let’s explore &lt;u&gt;why&lt;/u&gt; you might want to.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font face=Candara&gt;&lt;b&gt;Loosely-coupled routing&lt;/b&gt;. Imagine you have a client that interacts with a service (Figure 1a), but now you have a requirement to involve a third program that also needs to know about the information the client is exchanging with the service. How do you bring this third system into the mix? A conventional answer is to either make the original service a client of a new service (Figure 1b); or make the original client a client of two services (Figure 1c).&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;a href="http://byfiles.storage.live.com/y1pvhHyq8t_9gu31JTzZ0EnwP2SA08mgqV1VEBaxvRs8x0R_gNiaB0WRTFSfrPIe2XtAcrkiAgSreY" target="_blank"&gt;&lt;img height=200 alt="service_coupling" src="http://byfiles.storage.live.com/y1pvhHyq8t_9gu31JTzZ0EnwP2SA08mgqV1VEBaxvRs8x0R_gNiaB0WRTFSfrPIe2XtAcrkiAgSreY" width=239&gt;&lt;/a&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;i&gt;&lt;font size=3&gt;&lt;font face=Candara&gt;Figure 1: interconnecting services in code is not loose coupling&lt;/font&gt;&lt;/font&gt;&lt;/i&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt; &lt;/font&gt;&lt;font face=Candara size=3&gt;Neither of these answers is very satisfactory because they force you to tightly couple your routing. If you are a fan of SOA and value loose coupling in other areas of your work, this tight coupling of how your services are linked should offend you.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font face=Candara&gt;&lt;span&gt; &lt;/span&gt;In contrast, if your client and service are have an ESB interposed between them (Figure 2), the ESB can share information with other messaging parties. This approach helps keeps your services pure, context-free and reusable, as you don’t have to add program code to link services together.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;a href="http://byfiles.storage.live.com/y1pvhHyq8t_9guL4ChRp9yZd2XLTNcdp_LPTfFGP_dvWFVL3hZ6iOx0L8z6P5hFp3UWd9Y2GNeYgEs" target="_blank"&gt;&lt;img height=200 alt="service_coupling2" src="http://byfiles.storage.live.com/y1pvhHyq8t_9guL4ChRp9yZd2XLTNcdp_LPTfFGP_dvWFVL3hZ6iOx0L8z6P5hFp3UWd9Y2GNeYgEs" width=269&gt;&lt;/a&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;span&gt;&lt;font face=Candara size=3&gt;&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;&lt;em&gt;Figure 2: passing service traffic through the ESB easily accommodates additional parties.&lt;/em&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font face=Candara&gt;&lt;b&gt;Mediation of differences&lt;/b&gt;. You might have clients and services that can’t interact directly because they aren’t quite compatible, due to differences in transport, security model, message format, or semantics. You can connect each of them to an ESB, however, and the ESB can then interconnect them, mediating between&lt;a href="http://byfiles.storage.live.com/y1pvhHyq8t_9gttcbbmBqj3Jwit8CdrzXAoGmVsWV1ViFkm0B1S-a6ln4zDU4uxGIL0CQeFsBbriyg" target="_blank"&gt;&lt;/a&gt; their differences. &lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;&lt;a href="http://byfiles.storage.live.com/y1pvhHyq8t_9gtUL77M2XIhLR23-jLskedrcuTY4w28jUvLtrPB01ttPez7IPCGeNz2-PjYpWQ0BN4" target="_blank"&gt;&lt;img height=200 alt="service_coupling3" src="http://byfiles.storage.live.com/y1pvhHyq8t_9gtUL77M2XIhLR23-jLskedrcuTY4w28jUvLtrPB01ttPez7IPCGeNz2-PjYpWQ0BN4" width=270&gt;&lt;/a&gt; &lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;span&gt;&lt;font face=Candara size=3&gt;&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;&lt;em&gt;Figure 3: Mediation bridges differences in protocol, security model, message format, semantics&lt;/em&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font face=Candara&gt;&lt;b&gt;Workload Sharing&lt;/b&gt;. The ESB can work with multiple instances of services and share workload across them. You can freely add services instances or take them away while running; workload distribution automatically adjusts.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font face=Candara&gt;&lt;b&gt;When Worlds Collide&lt;/b&gt;. You can get services and non-services to work together. Neuron interconnects easily to services and clients using WCF. Neuron also interconnects to non-services such as legacy system and line-of-business systems using adapters. Once joined to the ESB, these programs can interact even though there be huge gap between the technologies they are use and when they were created.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font face=Candara&gt;&lt;b&gt;Auditing and Compliance Monitoring&lt;/b&gt;. You may want to keep an audit of your messages in order to show compliances with state, federal, or industry regulations. If your messaging traffic flows through the bus, the bus can take care of the rest.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt; &lt;/font&gt;&lt;font face=Candara size=3&gt; &lt;a href="http://byfiles.storage.live.com/y1pvhHyq8t_9gvHFR4liMp6Q7vxhJxbErOvoxqwrNE61JFv8hualWRUmLn-D2WCtDGbwL6E7mfNuL4" target="_blank"&gt;&lt;img height=200 alt="service_coupling4" src="http://byfiles.storage.live.com/y1pvhHyq8t_9gvHFR4liMp6Q7vxhJxbErOvoxqwrNE61JFv8hualWRUmLn-D2WCtDGbwL6E7mfNuL4" width=295&gt;&lt;/a&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt; &lt;/font&gt;&lt;i&gt;&lt;font face=Candara size=3&gt;Figure 4: Both services and non-services can work cooperatively&lt;/font&gt;&lt;/i&gt; 
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;The Mechanics of Service Pass-Through&lt;/font&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;When you define a service to Neuron (usually by importing metadata), one or more service endpoint definition(s) are created. By itself, a service definition is nothing more than an interesting record in a repository. I blogged yesterday about how you can use this repository to create WCF clients based on central configuration. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;Things get more interesting when you authorize service-pass through for your service definition. You can enable service pass-through for the client-side and/or the service-side, as shown in Figure 5.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt; &lt;a href="http://byfiles.storage.live.com/y1pvhHyq8t_9gs3hyMqeCw6j6xlOrY6gADQtHJxA-CQNZ7zmLdQi2fONs0LnH0KWbSVyBeiDRufQ-w" target="_blank"&gt;&lt;img height=200 alt="service_coupling5" src="http://byfiles.storage.live.com/y1pvhHyq8t_9gs3hyMqeCw6j6xlOrY6gADQtHJxA-CQNZ7zmLdQi2fONs0LnH0KWbSVyBeiDRufQ-w" width=271&gt;&lt;/a&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt; &lt;/font&gt;&lt;i&gt;&lt;font size=3&gt;&lt;font face=Candara&gt;Figure 5: A service definition with client- and service-side pass-through enabled&lt;/font&gt;&lt;/font&gt;&lt;/i&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;Enabling client-side pass through causes Neuron to create a &lt;b&gt;client connector&lt;/b&gt;, which is a hosting service for clients. This hosting service looks just like the client’s actual target service, with the same binding and security model. The only difference is that you point the client to a different address on the ESB Server. Client-side pass- through maps incoming client messages to an ESB topic and to a publisher. As client messages are received, the ESB publishes those messages on a topic. Any party with a subscription to that topic receives a copy of the message. This works for both 1-way and request-reply messaging.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;Enabling service-side pass through causes Neuron to create a &lt;b&gt;service connector&lt;/b&gt;, which is a client to the service used by the ESB Server. This client has a matching binding and security model for the service it is connecting to. The service connector is mapped to a topic and a subscriber. As messages are received over the ESB, the service connector passes them on to the service. Replies from the service are passed back over the bus to the originating client.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;span&gt;&lt;font face=Candara size=3&gt;&lt;/font&gt;&lt;/span&gt;
&lt;div&gt;&lt;a href="http://byfiles.storage.live.com/y1pvhHyq8t_9gv4eLXhlRbBP2bluTZzK3cjs5SpzoAq3aorxTP220Qv8zjvCunH--9a3kXd6PpmHBE" target="_blank"&gt;&lt;img height=200 alt="service_coupling6" src="http://byfiles.storage.live.com/y1pvhHyq8t_9gv4eLXhlRbBP2bluTZzK3cjs5SpzoAq3aorxTP220Qv8zjvCunH--9a3kXd6PpmHBE" width=244&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face=Candara size=3&gt;For true client-service pass-through, you w&lt;/font&gt;&lt;font face=Candara size=3&gt;ould enable both client-side and service-side pass-through. In some scenarios, you may choose to only enable one side or the other.&lt;/font&gt;&lt;/div&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;Notice that in service pass-through, you aren’t asked to modify your client and service in any way, other than to change the address the client points to. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;Service pass-through the ESB avoids tightly-coupled routing and keeps your services more modular and reusable. It allows for mediation between program differences and allows services and non-services to interact. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Candara size=3&gt;&lt;/font&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+Service+Pass-Through+in+Neuron+ESB&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!445.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!445.entry</guid><pubDate>Wed, 07 May 2008 01:37:39 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!445/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!445.entry#comment</wfw:comment><dcterms:modified>2008-05-07T15:10:22Z</dcterms:modified></item><item><title>Data Binding a Grid View to a WCF Service with Paging and Sorting Support</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!275.entry</link><description>&lt;div&gt;&lt;font size=2&gt;I've recently done some real-world project work with data binding against WCF services, including supporting grid view controls with paging and sorting, and thought I'd share my experiences. I started off using the &lt;/font&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/aa479339.aspx"&gt;&lt;font size=2&gt;ASP.NET GridView Samples on MSDN&lt;/font&gt;&lt;/a&gt;&lt;font size=2&gt; and this gave me a big head start.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;font size=2&gt;Project Background&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;First, some background. In a recent project, a 2-tier ASP.NET web site was being refactored to include a 3rd tier of WCF business services. The original design had a web presentation tier and data tier only. The ASP.NET pages used LLBLGEN (a popular ORM) for data access. In the new design, the goal was to add a business services tier and not use the ORM at all in the web pages. Rather, the web pages would call business-oriented service methods with operations tailored to make it easy for the web pages to work with. The ORM code was moved to the service tier. The result is a better arrangement of software layers, simpler code, and exposes much of the project's code assets for reuse elsewhere in the company.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;All well and good, except the web site uses data grid views extensively. The majority of the pages show information in Telerik RadGrid grid views, with paging and column sorting. The original implementation simply used the Object Data Source (ODS) that came with LLBLGEN, with paging end sorting enabled. Users were free to navigate through result pages and sort columns any way they wanted to interactively. The LLBLGEN ODS would do the appropriate things to pass just the data needed, sorted appropriately. The problem this posed in the refactoring is that we wanted the presentation tier to be very unaware of the implementation details encapsulated by the business services. Yet we needed to provide users with the same interactive behavior they were already used to.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;A lengthy philosophical discussion ensued, where various strategies were considered. Whatever approach we chose, we were going to be doing this over and over for many kinds of business entities, so we wanted to get it right the first time. How should business services be designed when user-directed paging and sorting are needed? One possibility we considered was to have services return a complete result set, but keep a snapshot of the result set at the presentation tier, perhaps in session state. Then paging and sorting would work off of that &amp;quot;local&amp;quot; data snapshot. We quickly rejected that approach, at least for this particular customer and project, because customers can perform searches yielding perhaps thousands or tens of thousands of matches and may only glance at one or two pages of the results. Given that behavior, we couldn't justify transferring the full result set to the presentation tier. Next we considered the alternative path of maintaining the notions of paging and sorting in our service contracts. It took awhile to decide how we felt about passing parameters like start row, max row count, and sort column name to a business service method, but we are now convinced this is a good and correct thing to do when your consumer is an interactive control along the lines of a grid view. This is the approach we adopted.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;font size=2&gt;Grid View Control Data Binding&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;Binding a grid view control to the object data source is simple. The object data source is declared, including specifying the names of key methods.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;ObjectDataSource&lt;/font&gt; &lt;font color="#ff0000"&gt;ID&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;ContactsDataSource&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;Runat&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;TypeName&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Contoso.Services.ContactServiceDataSource&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;SortParameterName&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;SortExpression&amp;quot;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#ff0000"&gt;SelectMethod&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;SelectRecords&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;EnablePaging&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;SelectCountMethod&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;TotalRecordCount&amp;quot;&lt;/font&gt; &lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;ObjectDataSource&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;p&gt;&lt;font size="+0"&gt;&lt;font size=2&gt;Binding a grid view control to the object data source is simple. The GridView element's DataSourceID attribute identifies the ODS. We also turn on paging and sorting of the grid by seeting the AllowPaging and AllowSorting attributes to true.&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;GridView&lt;/font&gt; &lt;font color="#ff0000"&gt;ID&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;ContactsGridView&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;AllowPaging&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BorderColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;White&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BorderStyle&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Ridge&amp;quot;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#ff0000"&gt;CellSpacing&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;CellPadding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;3&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;GridLines&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;None&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BackColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;White&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BorderWidth&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;2px&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;PageSize&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;20&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; &lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#ff0000"&gt;AutoGenerateColumns&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;False&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;DataSourceID&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;ContactsDataSource&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;Runat&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;AllowSorting&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;True&amp;quot;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;FooterStyle&lt;/font&gt; &lt;font color="#ff0000"&gt;ForeColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Black&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BackColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;#C6C3C6&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;FooterStyle&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;PagerStyle&lt;/font&gt; &lt;font color="#ff0000"&gt;ForeColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Black&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;HorizontalAlign&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Right&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BackColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;#C6C3C6&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;PagerStyle&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;HeaderStyle&lt;/font&gt; &lt;font color="#ff0000"&gt;ForeColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;#E7E7FF&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;Font-Bold&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BackColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;#4A3C8C&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;HeaderStyle&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;Columns&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;    &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;BoundField&lt;/font&gt; &lt;font color="#ff0000"&gt;HeaderText&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Contact ID&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;DataField&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;ContactId&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;SortExpression&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;ContactId&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;BoundField&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;    &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;BoundField&lt;/font&gt; &lt;font color="#ff0000"&gt;HeaderText&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Group Name&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;DataField&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;GroupName&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;SortExpression&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;GroupName&amp;quot;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#ff0000"&gt;DataFormatString&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;{0:c}&amp;quot;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;      &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ItemStyle&lt;/font&gt; &lt;font color="#ff0000"&gt;HorizontalAlign&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Right&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;ItemStyle&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;    &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;BoundField&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;    &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;BoundField&lt;/font&gt; &lt;font color="#ff0000"&gt;HeaderText&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Group Since&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;DataField&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;GroupSince&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;SortExpression&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;BusinessEmail&amp;quot;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#ff0000"&gt;DataFormatString&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;{0:d}&amp;quot;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;      &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ItemStyle&lt;/font&gt; &lt;font color="#ff0000"&gt;HorizontalAlign&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Right&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;ItemStyle&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;    &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;BoundField&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;    &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;BoundField&lt;/font&gt; &lt;font color="#ff0000"&gt;HeaderText&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Business Phone&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;DataField&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;BusinessPhone&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;BoundField&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;  &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;Columns&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;SelectedRowStyle&lt;/font&gt; &lt;font color="#ff0000"&gt;ForeColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;White&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;Font-Bold&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BackColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;#9471DE&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;SelectedRowStyle&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowStyle&lt;/font&gt; &lt;font color="#ff0000"&gt;ForeColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Black&amp;quot;&lt;/font&gt; &lt;font color="#ff0000"&gt;BackColor&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;#DEDFDE&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;RowStyle&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;asp&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#a31515"&gt;GridView&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;i&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;You are viewing page&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&amp;lt;%&lt;/font&gt;&lt;font face="Courier New" color="#0000ff"&gt;=&lt;/font&gt;&lt;font face="Courier New"&gt;ContactsGridView.PageIndex + 1%&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;of&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&amp;lt;%&lt;/font&gt;&lt;font face="Courier New" color="#0000ff"&gt;=&lt;/font&gt;&lt;font face="Courier New"&gt;ContactsGridView.PageCount%&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;i&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;&lt;strong&gt;&lt;font size=2&gt;Object Data Source&lt;/font&gt;&lt;/strong&gt;
&lt;div&gt;&lt;font size=2&gt;To create an object data source with paging and sorting turns out to be pretty straightforward. You implement a select method that accepts a start row, max row count, and sort column name parameter. In the code listing below, SelectRecords is the method and there are 4 overloads. The client control will call the most appropriate based on whether features like paging and sorting have been enabled. SortRecords calls FetchData in this code, which is responsible for fetching the requested information and returning it in the form of a dataset. FetchData calls a business service method. The service method has both search criteria parameters (a contact ID in this case) as well as the start row, max row count, and sort column parameters. By simply adopting the Object Data Source model down through the service tier, we end up with small and simple code.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;We decided to return the results in a dataset so that we could reuse this technique in a lot of different settings. Not everyones likes the idea of combining datasets and services, but I've found it to be very useful in scenarios where your services and clients are all internal to the same organization.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;Just returning a page of results isn't quite enough to make things work, as it turns out. Controls such as the grid view control or the Telerik Rad Grid control can't intelligently show you the number of pages available without knowing the &lt;u&gt;total&lt;/u&gt; record count, so it's necessary for a service call to return both a single page of results but also the total record count of the selection. We handled this by making the result dataset contain the page of result data in Tables[0] and the total record count in Tables[1]. The second table contains just one value in a single row, the total record count. The method TotalRecordCount is called to get the total record count.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#808080"&gt;///&lt;/font&gt;&lt;font color="#008000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#808080"&gt;///&lt;/font&gt;&lt;font color="#008000"&gt; Object Data Source - calls contact service methods to collect contact data, with paging and sorting support.&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#808080"&gt;///&lt;/font&gt;&lt;font color="#008000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&amp;lt;/summary&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;class&lt;/font&gt; &lt;font color="#2b91af"&gt;ContactServiceDataSource&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;{&lt;br&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&lt;font face="Courier New" size=2&gt;    // Copy of last result set. Table 1 is result data, Table 2 contains record count.&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;    private&lt;/font&gt; &lt;font color="#2b91af"&gt;DataSet&lt;/font&gt; SelectionDataset = &lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;;&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;&lt;font color="#008000"&gt;&lt;font face="Courier New" size=2&gt;    // Retrieve page of results.&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;    public&lt;/font&gt; &lt;font color="#2b91af"&gt;DataTable&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; SelectRecords()&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    {&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;        return&lt;/font&gt; SelectRecords(&lt;font color="#0000ff"&gt;int&lt;/font&gt;.MaxValue, 0, &lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;.Empty);&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    }&lt;/font&gt; 
&lt;p&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;    public&lt;/font&gt; &lt;font color="#2b91af"&gt;DataTable&lt;/font&gt; SelectRecords(&lt;font color="#0000ff"&gt;int&lt;/font&gt; maximumRows, &lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; startRowIndex)&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    {&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;        return&lt;/font&gt; SelectRecords(maximumRows, startRowIndex, &lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;.Empty);&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    }&lt;/font&gt; 
&lt;p&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;    public&lt;/font&gt; &lt;font color="#2b91af"&gt;DataTable&lt;/font&gt; SelectRecords(&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; SortExpression)&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    {&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;        return&lt;/font&gt; SelectRecords(&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;.MaxValue, 0, SortExpression);&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    }&lt;/font&gt; 
&lt;p&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;    public&lt;/font&gt; &lt;font color="#2b91af"&gt;DataTable&lt;/font&gt; SelectRecords(&lt;font color="#0000ff"&gt;int&lt;/font&gt; maximumRows, &lt;font color="#0000ff"&gt;int&lt;/font&gt; startRowIndex, &lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; sortExpression)&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    {&lt;br&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;        SelectionDataset = FetchData(maximumRows, startRowIndex, sortExpression);&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color="#0000ff"&gt;        return&lt;/font&gt;&lt;font face="Courier New"&gt; SelectionDataset.Tables[0];&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    }&lt;/font&gt; 
&lt;p&gt;&lt;font color="#008000"&gt;&lt;font face="Courier New" size=2&gt;    // Fetch data.&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;    private&lt;/font&gt; &lt;font color="#2b91af"&gt;DataSet&lt;/font&gt; FetchData(&lt;font color="#0000ff"&gt;int&lt;/font&gt; maximumRows, &lt;font color="#0000ff"&gt;int&lt;/font&gt; startRowIndex, &lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; sortExpression)&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    {&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;        ContosoContactClient contactClient = &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt; ContosoContactClient(&lt;font color="#a31515"&gt;&amp;quot;ContosoContactService&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;);&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color="#2b91af"&gt;        DataSet&lt;/font&gt;&lt;font face="Courier New"&gt; results = contactClient.GetGroupContactsByContactId(ContactId, startRowIndex, maximumRows, sortExpression);&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;&lt;font size=2&gt;&lt;font face="Courier New" color="#0000ff"&gt;        return&lt;/font&gt;&lt;font face="Courier New"&gt; results;&lt;br&gt;    }&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;&lt;font color="#008000"&gt;&lt;font face="Courier New" size=2&gt;    // Return total record count.&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;&lt;br&gt;    public&lt;/font&gt; &lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; TotalRecordCount()&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    {&lt;br&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font face="Courier New" size=2&gt;        try&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;        {&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;            if&lt;/font&gt; (SelectionDataset == &lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;)&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color="#0000ff"&gt;                return&lt;/font&gt;&lt;font face="Courier New"&gt; 0;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font face="Courier New" size=2&gt;            else&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;                return&lt;/font&gt; &lt;font color="#2b91af"&gt;Convert&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;.ToInt32(SelectionDataset.Tables[1].Rows[0].ItemArray[0]);&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;        }&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;        catch&lt;/font&gt; (&lt;font color="#2b91af"&gt;Exception&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; ex)&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;        {&lt;br&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;            LogException(ex);&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New" color="#0000ff"&gt;            return&lt;/font&gt;&lt;font face="Courier New"&gt; 0;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;        }&lt;br&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    }&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;font size=2&gt;Service Contract&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;The service contract operations that are consumed by an object data source include the parameters for start row, max rows, and sort column. The implementation code, of course, has to make good on these criteria. This is fairly easy to do with a SQL Server Stored Procedure or, in the case of this project, an ORM like LLBLGEN.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;br&gt;    [&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#2b91af"&gt;ServiceContract&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;]&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color="#0000ff"&gt;    public&lt;/font&gt; &lt;font color="#0000ff"&gt;interface&lt;/font&gt; &lt;font color="#2b91af"&gt;IContosoContactService&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    {&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;        [&lt;/font&gt;&lt;font face="Courier New" color="#2b91af"&gt;OperationContract&lt;/font&gt;&lt;font face="Courier New"&gt;]&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#2b91af"&gt;        &lt;/font&gt;...&lt;br&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;        [&lt;/font&gt;&lt;font face="Courier New" color="#2b91af"&gt;OperationContract&lt;/font&gt;&lt;font face="Courier New"&gt;]&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color="#2b91af"&gt;        GroupContactCollection&lt;/font&gt; GetGroupContactsByContactId(&lt;font color="#0000ff"&gt;int&lt;/font&gt; contactId, &lt;font color="#0000ff"&gt;int&lt;/font&gt; startRow, &lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; rowCount, &lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font face="Courier New"&gt; sortColumn&lt;/font&gt;);&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" size=2&gt;    }&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;I won't go into the mechanics of the service method implementation here, as it was done by another developer and is ORM-specific. Without an ORM you would have a SQL Server stored procedure pull the results, then pass back just the total record count and the requested page worth of result data.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size=2&gt;The end result of all this is that we've moved the project to a 3-tier service-oriented application design without losing the interactive capabilities (grid paging, sorting) or the efficiency of data movement we had in the past. Although it took a bit of puttering the first time around, the Object Data Source approach is straightforward and the code we've ended up with is small and simple.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+Data+Binding+a+Grid+View+to+a+WCF+Service+with+Paging+and+Sorting+Support&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!275.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!275.entry</guid><pubDate>Wed, 17 Oct 2007 18:56:57 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!275/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!275.entry#comment</wfw:comment><dcterms:modified>2007-10-17T21:23:27Z</dcterms:modified></item><item><title>WCF Tips #7 - Clients</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!263.entry</link><description>&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;font color="#000000"&gt;&lt;strong&gt;David Pallmann’s WCF Tips #7 - Clients&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;a&gt;&lt;font face=Cambria color="#365f91" size=5&gt;Clients&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Use a Robust Client&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Don’t use generated proxy clients, which make no provision for recovering from errors. Use robust client code that retries failed communications on time-out and re-created proxies on communication failures.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Rationale: &lt;/b&gt;Generating a WCF client from metadata is easy and gets you started quickly. Unfortunately, this code does not handle errors. In real-world solutions, WCF clients need to do the following:&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;font size=3&gt;Retry on minor failures: &lt;/font&gt;&lt;/b&gt;&lt;font size=3&gt;A minor failure such as a time-out should not abort processing; a limited number of retries is in order before giving up on an access. Code a small (and configurable) retry count and re-issue invocations after minor failures.&lt;b style=""&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;font size=3&gt;Recreate proxy on major failures: &lt;/font&gt;&lt;/b&gt;&lt;font size=3&gt;A major failure such as a faulted communication object should result in re-creation of the proxy to the service, then a retry as described above. &lt;b style=""&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font color="#000000" size=3&gt; &lt;/font&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+WCF+Tips+%237+-+Clients&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!263.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!263.entry</guid><pubDate>Wed, 26 Sep 2007 03:31:38 GMT</pubDate><slash:comments>9</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!263/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!263.entry#comment</wfw:comment><dcterms:modified>2007-09-26T03:31:38Z</dcterms:modified></item><item><title>WCF Tips #6 - Instrumentation</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!262.entry</link><description>&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;font color="#000000"&gt;&lt;strong&gt;David Pallmann’s WCF Tips #6 - Instrumentation&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;strong&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;a&gt;&lt;font face=Cambria color="#365f91" size=5&gt;Instrumentation&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Enable Metadata Reporting&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; WCF services can be self-describing by automatically generating metadata. This is not enabled by default , so &lt;u&gt;remember to enable metadata reporting in your service configuration&lt;/u&gt;.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; Service metadata is what allows clients to easily generate proxies. There are few reasons to suppress metadata other than some extreme security scenarios. As a general rule, enable metadata reporting for your services.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; Would-be consumers of your service won’ t be able to generate client proxy code. Some may choose not to use your service as a result.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;b style=""&gt;&lt;font color="#000000" size=3&gt;How to do it:&lt;/font&gt;&lt;/b&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;span style="font-size:10pt;color:blue;line-height:115%;font-family:'Lucida Console'"&gt;&lt;span style=""&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:10pt;color:maroon;line-height:115%;font-family:'Lucida Console'"&gt;behaviors&lt;/span&gt;&lt;span style="font-size:10pt;color:blue;line-height:115%;font-family:'Lucida Console'"&gt;&amp;gt;&lt;br&gt;&lt;span style=""&gt;        &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:10pt;color:maroon;line-height:115%;font-family:'Lucida Console'"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="font-size:10pt;color:blue;line-height:115%;font-family:'Lucida Console'"&gt;&amp;gt;&lt;br&gt;&lt;span style=""&gt;            &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:10pt;color:maroon;line-height:115%;font-family:'Lucida Console'"&gt;behavior&lt;/span&gt;&lt;span style="font-size:10pt;line-height:115%;font-family:'Lucida Console'"&gt;&lt;font color="#000000"&gt; name=&amp;quot;metadataSupport&amp;quot;&lt;/font&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;br&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style=""&gt;        &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:maroon"&gt;serviceMetadata&lt;/span&gt;&lt;font color="#000000"&gt; httpGetEnabled=&amp;quot;true&amp;quot; httpGetUrl=&amp;quot;&amp;quot;&lt;/font&gt;&lt;span style="color:blue"&gt;/&amp;gt;&lt;br&gt;&lt;span style=""&gt;            &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon"&gt;behavior&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;br&gt;&lt;span style=""&gt;        &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;br&gt;&lt;span style=""&gt;    &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon"&gt;behaviors&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Enable WMI Instrumentation&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; WCF is richly instrumented to report status information via Windows Management Instrumentation (WMI). This is not enabled by default, so &lt;u&gt;remember to enable it in your service configuration&lt;/u&gt;.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; Enterprises frequently invest in monitoring tools to track the health and activity of systems and applications. Windows Management Instrumentation (WMI) is a popular way to report such information and is support by a wide variety of monitoring product such as Microsoft Operations Manager and HP OpenView. &lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; Enterprise monitoring will be largely blind to the existence and health of your services.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;b style=""&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;How to do it:&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;
&lt;p style="margin:0in 0in 10pt 0.5in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-size:10pt;line-height:115%;font-family:Consolas"&gt;&amp;lt;system.serviceModel&amp;gt;&lt;br&gt;&lt;span style=""&gt;    &lt;/span&gt;&amp;lt;diagnostics wmiProviderEnabled=&amp;quot;true&amp;quot; /&amp;gt; &lt;br&gt;&amp;lt;/system.serviceModel&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas"&gt;&lt;/span&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font color="#000000" size=3&gt; &lt;/font&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+WCF+Tips+%236+-+Instrumentation&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!262.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!262.entry</guid><pubDate>Wed, 26 Sep 2007 03:30:55 GMT</pubDate><slash:comments>8</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!262/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!262.entry#comment</wfw:comment><dcterms:modified>2007-09-26T03:30:55Z</dcterms:modified></item><item><title>WCF Tips #5 - Infrastructure</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!261.entry</link><description>&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;font color="#000000"&gt;&lt;strong&gt;David Pallmann’s WCF Tips #5 - Infrastructure&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;strong&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;a&gt;&lt;font face=Cambria color="#365f91" size=5&gt;Infrastructure&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Right-Size Your Infrastructure&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Make use of some service infrastructure, and size it right. In particular, make up for areas WCF doesn’t provide strong support for, such as loosely-coupled routing and centralized management.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font color="#000000" size=3&gt;Hint: The extremes of &lt;i style=""&gt;no infrastructure at all&lt;/i&gt; and a &lt;i style=""&gt;bloated infrastructure&lt;/i&gt; are to be avoided. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Rationale: &lt;/b&gt;If a company is seriously pursuing SOA, there are going to be a lot of services and clients eventually. There is going to be a need for some infrastructure to complement the business services. UDDI directories, message brokers, and Enterprise Service Buses are all examples of SOA infrastructure. With good SOA infrastructure in place, the configuration of services and their interconnections can be managed centrally at the enterprise level.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;                &lt;/span&gt;SOA infrastructure services should be as thin as possible (a “thinfrastructure”), expanded as needed, and build solidly on service standards. Infrastructure services can serve purposes such as these:&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Directory of services&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Message router&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Message transformation&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Rules service&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Workflow host&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Integration adapter&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Activity monitor&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; You’ll lose the flexibility to provide good change management. Failure to provide any SOA infrastructure eventually results in a set of clients and services that work together as initially designed but can’t easily be changed individually. &lt;/font&gt;&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Use a Discovery Mechanism to Locate Services&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Find other services using a discovery mechanism, such as a directory. &lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; The default way WCF clients identify services is to define their endpoints in an application configuration file. This can become unwieldy if there are a large number of services and clients in use. A better approach is to have clients locate services through a discovery mechanism.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;                &lt;/span&gt;Possible discovery mechanisms include the following:&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;font size=3&gt;Direct Discovery&lt;/font&gt;&lt;/b&gt;&lt;font size=3&gt;: Use a protocol such as WS-Discovery over UDP. A client broadcasts a search request and matching parties respond. Because we don’t have this capability in WCF yet, this is not a recommended technique.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;font size=3&gt;Registry Discovery&lt;/font&gt;&lt;/b&gt;&lt;font size=3&gt;: Service information is contained in a registry, such as a UDDI registry or a custom “locator service”. Clients query the registry to find an appropriate service to talk to.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;b style=""&gt;Mediated Discovery&lt;/b&gt;:&lt;b style=""&gt; &lt;/b&gt;&lt;/font&gt;&lt;font size=3&gt;Services and clients interconnect through an intermediary, such as a Message Broker an Enterprise Service Bus (ESB). The intermediary puts clients and services together.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; If each client and service has to be configured locally, you’re going to find it difficult to view or modify your configuration from an enterprise-level perspective.&lt;/font&gt;&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Use a Loosely-Coupled Routing Mechanism&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Avoid tying services together directly. Use a configurable routing mechanism to connect clients in a loose-coupled fashion.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;Rationale: &lt;/b&gt;WCF is a great technology that champions loose-coupling, but it makes no provision at all for loosely-coupled routing. If a service in turn becomes a client of additional services, you have a tightly coupled situation. Instead, each service should exist on its own as a truly reusable component. The interconnections between services should be handled by a flexible router. Routing can be accomplished by an Enterprise service Bus, or a Message Broker such as BizTalk.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; You’re going to run into the classic point-to-point problem, where it becomes more and more expensive to integrate and manage systems. Help them find each other with a good discovery mechanism.&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+WCF+Tips+%235+-+Infrastructure&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!261.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!261.entry</guid><pubDate>Wed, 26 Sep 2007 03:30:00 GMT</pubDate><slash:comments>14</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!261/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!261.entry#comment</wfw:comment><dcterms:modified>2007-09-26T03:31:55Z</dcterms:modified></item><item><title>WCF Tips #4 - Configuration</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!260.entry</link><description>&lt;div&gt;
&lt;h1 style="margin:24pt 0in 0pt"&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;font color="#000000"&gt;David Pallmann’s WCF Tips #4 - Configuration&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;h1 style="margin:24pt 0in 0pt"&gt;
&lt;h1 style="margin:24pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#365f91" size=5&gt;Configuration&lt;/font&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Challenge the Default Settings&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;Tip: Learn the appropriate knobs to turn to make WCF perform for you. Don’t assume the defaults are best, in many cases they aren’t. &lt;i&gt;Specifics are addressed in several related tips.&lt;/i&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;Rationale: Some of the default settings in WCF are great. Some of them aren’t. Some of them, in the name of being secure out-of-box, prevent you performing useful work!&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;What if I Don’t? Your production deployments will fail.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;Examples:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri&gt;&lt;font size=3&gt;Instancing&lt;/font&gt;&lt;font size=3&gt;: the default is Per Session, but you’re better off writing stateless services. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri&gt;&lt;font size=3&gt;Bindings:&lt;/font&gt;&lt;font size=3&gt; default quota settings severely limit message size, depth, and complexity.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri&gt;&lt;font size=3&gt;Service Hosting: &lt;/font&gt;&lt;font size=3&gt;default settings limit the number of concurrent clients and sessions.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Choose the Right Binding for the Right Purpose, then Fine-Tune it&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;Tip: Use the correct binding for your endpoints. First choose the right general binding. Then fine-tune the binding for its purpose.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;Rationale: A binding is a pre-packaged profile that controls a great deal about how communication will take place. The key characteristics of a binding are transport and security model, but there is much more under its control. The choice of binding also affects reliability, transaction support, and quota settings such as maximum message size. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt;text-indent:0.5in"&gt;&lt;font face=Calibri color="#000000" size=3&gt;It’s first and foremost important to select the right general binding. The importance of these factors will point you to the right binding to use.&lt;/font&gt; 
&lt;p style="margin:0in 0in 0pt 0.75in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span&gt;&lt;span&gt;&lt;font face=Calibri size=3&gt;1.&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Desired interop level.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 0pt 0.75in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span&gt;&lt;span&gt;&lt;font face=Calibri size=3&gt;2.&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Desired security model.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 0pt 0.75in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span&gt;&lt;span&gt;&lt;font face=Calibri size=3&gt;3.&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Desired reliability.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 0pt 0.75in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span&gt;&lt;span&gt;&lt;font face=Calibri size=3&gt;4.&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Desired transport.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt 0.75in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span&gt;&lt;span&gt;&lt;font face=Calibri size=3&gt;5.&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Desired transaction support.&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt;text-indent:0.5in"&gt;&lt;font face=Calibri color="#000000" size=3&gt;Secondly, you should fine tune your binding. Just because a binding supports your preferred security model, reliability level, or transaction capability doesn’t mean those things are enabled by default. Get acquainted with your binding’s properties and configure their values to fit your needs. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;What if I Don’t? You’ll get the luck of the draw. Fortunately, it’s easy to change your mind about bindings down the road.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;Example: A service is being created that must be accessible by a partner company. The partner company only has experience with &lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Configure Bindings to Enable Doing Real Work&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;Tip: Override the debilitating default properties of bindings so that you can get real work done. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;Rationale: In the name of shipping “securely by default”, WCF Services have great limitations on the amount of work they can perform. To get real levels of work done in the enterprise requires overriding many default values. Some of these values are in the binding properties, while others are found in the ServiceHost object. There are limitations on message size, string size, XML depth, array length, and other areas that will make calls fail if not set to real-world values.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;span&gt;                &lt;/span&gt;Of course, these limits were set with good intentions such as preventing denial of service attacks. Don’t override the binding properties with values larger than you need.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;What if I Don’t? You’ll run into limitations at runtime, such as not being able to support large or complex messages.&lt;/font&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font face=Calibri color="#000000" size=3&gt;Example: Here’s an example of overriding binding properties. This example is in code, but you can perform the equivalent in your XML configuration file. Be sure to use reasonable values for your needs, &lt;u&gt;not&lt;/u&gt; Int32.MaxValue as shown. Refer to the documentation for the precise meaning of these properties.&lt;/font&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;span&gt;&lt;font color="#000000"&gt;    &lt;/font&gt;&lt;/span&gt;&lt;span style="color:#2b91af"&gt;NetTcpBinding&lt;/span&gt;&lt;font color="#000000"&gt; binding = &lt;/font&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color:#2b91af"&gt;NetTcpBinding&lt;/span&gt;&lt;font color="#000000"&gt;();&lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span&gt;    &lt;/span&gt;binding.ReaderQuotas.MaxDepth = &lt;/font&gt;&lt;span style="color:#2b91af"&gt;Int32&lt;/span&gt;&lt;font color="#000000"&gt;.MaxValue;&lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span&gt;    &lt;/span&gt;binding.ReaderQuotas.MaxStringContentLength = &lt;/font&gt;&lt;span style="color:#2b91af"&gt;Int32&lt;/span&gt;&lt;font color="#000000"&gt;.MaxValue;&lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span&gt;    &lt;/span&gt;binding.ReaderQuotas.MaxArrayLength = &lt;/font&gt;&lt;span style="color:#2b91af"&gt;Int32&lt;/span&gt;&lt;font color="#000000"&gt;.MaxValue;&lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span&gt;    &lt;/span&gt;binding.ReaderQuotas.MaxBytesPerRead = &lt;/font&gt;&lt;span style="color:#2b91af"&gt;Int32&lt;/span&gt;&lt;font color="#000000"&gt;.MaxValue;&lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span&gt;    &lt;/span&gt;binding.ReaderQuotas.MaxNameTableCharCount = &lt;/font&gt;&lt;span style="color:#2b91af"&gt;Int32&lt;/span&gt;&lt;font color="#000000"&gt;.MaxValue;&lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span&gt;    &lt;/span&gt;binding.ReaderQuotas.MaxStringContentLength = &lt;/font&gt;&lt;span style="color:#2b91af"&gt;Int32&lt;/span&gt;&lt;font color="#000000"&gt;.MaxValue;&lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span&gt;    &lt;/span&gt;binding.MaxReceivedMessageSize = &lt;/font&gt;&lt;span style="color:#2b91af"&gt;Int32&lt;/span&gt;&lt;font color="#000000"&gt;.MaxValue;&lt;/font&gt;&lt;/span&gt; 
&lt;p style="margin:0in 0in 10pt"&gt;&lt;span style="font-size:10pt;line-height:115%;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span&gt;    &lt;/span&gt;binding.MaxConnections = 1000;&lt;/font&gt;&lt;/span&gt; &lt;/h1&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+WCF+Tips+%234+-+Configuration&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!260.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!260.entry</guid><pubDate>Wed, 26 Sep 2007 03:29:00 GMT</pubDate><slash:comments>30</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!260/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!260.entry#comment</wfw:comment><dcterms:modified>2007-09-26T03:32:23Z</dcterms:modified></item><item><title>WCF Tips #3 - Service Hosting</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!259.entry</link><description>&lt;div&gt;
&lt;h1 style="margin:24pt 0in 0pt"&gt;&lt;span style="font-size:14pt;line-height:115%;font-family:'Calibri','sans-serif'"&gt;&lt;font color="#000000"&gt;David Pallmann’s WCF Tips #3 - Service Hosting&lt;/font&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;h1 style="margin:24pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#365f91" size=5&gt;Service Hosting&lt;/font&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Select a Service Hosting Method that Best Suits Your Needs&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Consider IIs and non-IIS hosting for services rather than just using the method more familiar to you. Leverage IIS hosting if you need its features (such as health monitoring) and your customers are willing to deploy IIS. Use direct hosting, such as in a Windows Service Application, if more appropriate. &lt;i style=""&gt;Note: the author hosts WCF services in Windows Services nearly all the time.&lt;/i&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; Previous Microsoft communication technologies tend to have a single hosting model, but WCF services can be hosted either in IIS or by the developer’s own code (essentially from any managed code environment). Developers should be aware of their hosting options and use the most appropriate one for their scenario. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt;text-indent:0.5in"&gt;&lt;font face=Calibri color="#000000" size=3&gt;IIS-hosted services provide a number of compelling features, including automatic activation, health monitoring, process recycling, compile-on-demand, and the ability to update the application or its config while still running. IIS also makes it easy to accomplish some things that are hard to do in code, such as supporting SSL. However, IIS also has some limitations. Not all customers are willing to deploy it. You are limited to the HTTP/S transport (unless using IIS 7.0). And the periodic process recycling that IIS/ASP.NET undergoes can sever a client’s session and security content unexpectedly.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;span style=""&gt;                &lt;/span&gt;Hosting a service yourself gives you more control over the lifetime of the service, but at the expense of the aforementioned IIS feature s unless you have an alternative implementation. Many developers and I.T. personnel find using a Windows Service Application more attractive. &lt;i style=""&gt;Neudesic provides a universal service host implemented in a Windows Service Application container, written by Chris Rolon&lt;/i&gt;. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; You may be taking the hard way if you aren’t familiar with all of your options.&lt;i style=""&gt;&lt;/i&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;b style=""&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;Examples: &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;A service is being created that is public-facing and must use HTTPS. The developer chooses to host the service in IIS because it is easiest to set up the SSL certificate that way.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;A service is being created that has a dependency on several other services running on the same machine. The developer decides to host the services in Windows Service Applications so that the Windows Service Controller can enforce the dependencies.&lt;/font&gt;&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Configure ServiceHost to Enable Doing Real Work&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; If hosting your service directly, configure your ServiceHost object. Override the debilitating default properties so that you can get real work done. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; In the name of shipping “securely by default”, WCF Services have great limitations on the amount of work they can perform. To get real levels of work done in the enterprise requires overriding many default values. Some of these values are in the ServiceHost object, while others apply to the binding of endpoints.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;span style=""&gt;                &lt;/span&gt;Of course, these limits were set with good intentions such as preventing denial of service attacks. Don’t override the ServiceHost properties with values larger than you need.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; You’ll run into limitations at runtime, such as not being able to support more than 10 clients at a time.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Example:&lt;/b&gt; The author routinely initializes a ServiceHost object this way:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;       &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/font&gt;&lt;span style="color:gray"&gt;//&lt;/span&gt;&lt;span style="color:green"&gt; Set throttling permissions to allow many concurrent service connections.&lt;/span&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New'"&gt; &lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New'"&gt; &lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;span style=""&gt;&lt;font color="#000000"&gt;        &lt;/font&gt;&lt;/span&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color:blue"&gt;static&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color:blue"&gt;void&lt;/span&gt;&lt;font color="#000000"&gt; SetServiceHostThrottle(&lt;/font&gt;&lt;span style="color:#2b91af"&gt;ServiceHost&lt;/span&gt;&lt;font color="#000000"&gt; host)&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;span style=""&gt;&lt;font color="#000000"&gt;            &lt;/font&gt;&lt;/span&gt;&lt;span style="color:#2b91af"&gt;ServiceThrottlingBehavior&lt;/span&gt;&lt;font color="#000000"&gt; throttle;&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;            &lt;/span&gt;throttle = host.Description.Behaviors.Find&amp;lt;&lt;/font&gt;&lt;span style="color:#2b91af"&gt;ServiceThrottlingBehavior&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt;();&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;span style=""&gt;&lt;font color="#000000"&gt;            &lt;/font&gt;&lt;/span&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt;&lt;font color="#000000"&gt; (throttle == &lt;/font&gt;&lt;span style="color:blue"&gt;null&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;                &lt;/span&gt;throttle = &lt;/font&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color:#2b91af"&gt;ServiceThrottlingBehavior&lt;/span&gt;&lt;font color="#000000"&gt;();&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;                &lt;/span&gt;throttle.MaxConcurrentCalls = 1000;&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;                &lt;/span&gt;throttle.MaxConcurrentInstances = 1000;&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;                &lt;/span&gt;throttle.MaxConcurrentSessions = 1000;&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;                &lt;/span&gt;host.Description.Behaviors.Add(throttle);&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;                &lt;/span&gt;host.CloseTimeout = &lt;/font&gt;&lt;span style="color:#2b91af"&gt;TimeSpan&lt;/span&gt;&lt;font color="#000000"&gt;.FromSeconds(1);&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal"&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;span style="font-size:10pt;line-height:115%;font-family:'Courier New'"&gt;&lt;font color="#000000"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/font&gt;&lt;/span&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+WCF+Tips+%233+-+Service+Hosting&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!259.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!259.entry</guid><pubDate>Wed, 26 Sep 2007 03:27:56 GMT</pubDate><slash:comments>4</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!259/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!259.entry#comment</wfw:comment><dcterms:modified>2007-09-26T03:32:36Z</dcterms:modified></item><item><title>WCF Tips #2 - Service Class Design</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!258.entry</link><description>&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%"&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;strong&gt;David Pallmann’s WCF Tips&lt;span style=""&gt;  #2 - Service Class Design&lt;/span&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%"&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;strong&gt;&lt;span style=""&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:14pt;line-height:115%"&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;strong&gt;&lt;span style=""&gt;&lt;a&gt;&lt;font face=Cambria color="#365f91" size=5&gt;Service Class Design&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Separate Service Interfaces from Service Implementation Classes&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Tip:&lt;span style=""&gt;  &lt;/span&gt;Separate your service implementation class from your service interface definition, and put the implementation in its own class away from other code. Use the same names for both but prefix the service interface with an I.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Rationale: The core reason for using service orientation is that the public contracts can be maintained while the internal implementation is replaceable. Although WCF allows you combine a service contract and its implementation in the same class, doing so undermines this principle. Instead, treat both service contracts (interfaces) and implementation classes as important but separate entities. The relation between the two is explicit in the code (the service class x implements Ix), and also implied by their similar names (Ix is the interface implemented by x).&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;What if I Don’t? You’ll tie your interfaces to their implementations, defeating the primary reason to use service orientation. At some point you’ll need to reimplement something and regret it.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Example: A service is needed to track time clocking. The service contract is defined as interface ITimeClock and maintained in its own source file, ITimeClock.cs. The service implementation is defined as class TimeClock and maintained&lt;span style=""&gt;  &lt;/span&gt;in its own source file, TimeClock.cs. &lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Consciously Select an Instancing Model&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Tip: Make an up-front decision about which instancing model you will use (per call, per session, shared session,&lt;span style=""&gt;  &lt;/span&gt;singleton) and specify it in a ServiceBehavior attribute, even if you are using the default instancing model of per session.&lt;span style=""&gt;  &lt;/span&gt;Keep the instancing model clearly in mind as the class’s members are defined, backed up with comments where necessary. Base the decision on what will work best for your service implementation.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Rationale: WCF instancing is easy to specify and easy to change, using a ServiceBehavior attribute, but the code has to be written with a particular instancing model is mind. The consequences of changing instancing models without changing the code as to match can be severe. For example, a class member variable can be a global value or a client-specific value depending on the instancing model.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;What if I Don’t? Your code likely won’t work correctly. Regrettably, this may not be immediately apparent until you have enough concurrent traffic.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Example: A developer creates a service, neither specifying an instancing model nor giving thought to one. Initial testing of the service with a single client appears to pass with flying colors. Later, when there are multiple clients accessing the service, serious problems arise because the use of class instances, member variables , and static variables was not in accordance with a specific instancing model.&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Avoid Stateful Services&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Tip: Where possible, avoid session state. Favor the Per Call or Singleton instancing modes. Stateful services should be the exception and stateless services the rule.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;span style=""&gt; &lt;/span&gt;Rationale: Stateless services are far more versatile as a reusable software component. They are easier to scale, tend to have simpler implementations, and can be used in a broader set of contexts.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt;text-indent:0.5in"&gt;&lt;font size=3&gt;Be willing to make an exemption when you need to. Stateful services are sometimes necessary, which is why WCF supports them--but they should be the exception, not the rule.&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Write Thread-Safe Code&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Tip: Write thread-safe code, so your service can take advantage of multiple-thread concurrency (the default behavior). If it is not possible to write thread-safe code for some reason, be sure to set concurrency mode to single.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Rationale: There are few reasons today to write application code that is not thread-safe, and WCF’s default concurrency mode expects this. Use appropriate synchronization mechanisms to access shared resources. Multiple concurrency and thread-safe code will provide your service with the best performance, especially in a setting many clients.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;What if I Don’t? Your code will run unsafely and/or inefficiently.&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Avoid Lengthy Service Operations&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Tip: Avoid lengthy service operations that may time out before they have completed executing. This is primarily a concern with 2-way operations where a client is awaiting results. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Rationale: WCF service operations can time out, and there are time-out settings on both the service-side and the client-side. You really have no good way to know how much time there is for your code to run before a time-out occurs somewhere, and once you venture past 30 or 60 seconds you are pushing your luck. A time-out is especially difficult to handle on the client-side of things. Did the service get the client’s request and process it or not? All the client knows is that a reply didn’t come back in time.&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;Approaches: If a service is returning a result list that may potentially be quite large, consider one of these solutions:&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Scope the Results. Design the service operation to allow input parameters that set a limit on the size of the results, such as a date range or a maximum record count.&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Results Chunking. Enforce a maximum result size and return a partial list of results. Provide a mechanism for the client to request additional chunks of the results. &lt;/font&gt;
&lt;p style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;Deflate the Results. Return a subset of result fields to keep the size small, and offer a method to retrieve detail for select row(s).&lt;/font&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+WCF+Tips+%232+-+Service+Class+Design&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!258.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!258.entry</guid><pubDate>Wed, 26 Sep 2007 03:26:36 GMT</pubDate><slash:comments>8</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!258/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!258.entry#comment</wfw:comment><dcterms:modified>2007-09-26T03:32:49Z</dcterms:modified></item><item><title>WCF Tips #1 - Service Interface Design</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!257.entry</link><description>&lt;div&gt;
&lt;p style="margin:0in 0in 10pt;tab-stops:right 6.5in"&gt;&lt;b style=""&gt;&lt;span style="font-size:14pt;line-height:115%"&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;David Pallmann’s WCF Tips&lt;span style=""&gt;  #1 - Service Interface Design&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;
&lt;p style="margin:0in 0in 5pt;tab-stops:right dotted 467.5pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#365f91" size=5&gt;Service Interface Design&lt;/font&gt;&lt;/a&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Design Service Contracts that are Themed and Indivisible&lt;/font&gt;&lt;/a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt; &lt;/font&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Tip: &lt;/b&gt;Ensure service contracts have a theme (purpose). Avoid combining unrelated service operations in the same contract; only include operations that contribute to the theme. This is also a SOA best practice.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Rationale: &lt;/b&gt;A service interface is supposed to be indivisible—that’s why we use the word &lt;i style=""&gt;contract&lt;/i&gt;. If a service contract has a purpose or theme and all of the operations in the contract contribute to that theme, the contract design is likely to be strong and survive. In contrast, throwing many unrelated operations into the same service contract under a weak premise, such as “all the public services my company exposes to partners”, is not likely to stand the test of time.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; The longevity of your service contracts may be compromised.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;b style=""&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;Examples: &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;
&lt;p style="margin:0in 0in 0pt 37.5pt;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;A bad example is a service whose theme is “Data Access”: this is far too vague a purpose for a service and invites every operation method that reads or writes to find a home here. &lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 0pt 37.5pt;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Another bad example is a service whose theme is inventory control but contains operations for both inventory control and truck delivery routing. Although the theme is reasonable, the operations do not all contribute to the theme, threatening to fracture the service into multiple services down the road.&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt 37.5pt;text-indent:-0.25in"&gt;&lt;font color="#000000"&gt;&lt;span style="font-family:Symbol"&gt;&lt;span style=""&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="font:7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;A good example is a service whose theme is order placement, and whose operations pertain only to creating, updating, canceling, or inquiring the status of orders.&lt;/font&gt;&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Design coarsely-grained methods&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Your service should favor coarse methods that are called less frequently as opposed to granular methods called frequently. In other words, think chunky. This is also a SOA best practice.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; Invoking a WCF service operation has unknown expense. Factors affecting expense include transport, distance, security model, encoding, reliability level, and transactability. Therefore, the best practice is to always assume service invocations are costly and seek to minimize them.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; Overhead will increase, possibly substantially.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Example: &lt;/b&gt;Your service needs to provide an operation for retrieving the transaction history of a client. A bad approach is to require a separate call to retrieve each individual transaction record. A good approach is to provide the full history as the result of a single call. An even better approach is to allow the scope of the results to be specified by the caller (such as a date range).&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Take Advantage of One Way Operations&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Use the most efficient messaging pattern for each operation. Don’t return a result if there is no use for it. Specify the asynchronous IsOneWay=true setting for an operation if a client doesn’t need to wait for the operation to complete. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; By default, a service operation is accessed in a request-reply pattern, and a client blocks after making a request until a reply has been received. This is true even if the return type of the method is void. However, service operations that don’t return a value can also be marked one way which allows a client to continue without waiting for a reply.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Example: &lt;/b&gt;Your service contract includes an operation named Archive which takes some time to execute. There are no results to return the client. You mark the operation IsOneWay=true so the client can initiate the operation without having to wait for its completion.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Use Data Structures Familiar to your Consumers&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Use data types in service operations that are familiar to your clients. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; Often the designer of a service will have some notion of who the consumers will be. While this may be a diluted concept in the case of a public service open to the Internet, that is the exception rather than the rule. The majority of services are designed for consumption within a department, within a company, or within a company’s value chain or industry. Leveraging this knowledge results in a service contract design that is more natural to its consumers.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;What if I Don’t?&lt;/b&gt; You’ll create unnecessary work for your consumers.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Example:&lt;/b&gt; A developer designs a service that will allow uploading of application forms. Because the intended consumers are in the health service industry, the developer supports an XML structure that is commonly used in the health care industry rather than inventing a new structure.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;h2 style="margin:10pt 0in 0pt"&gt;&lt;a&gt;&lt;font face=Cambria color="#4f81bd" size=4&gt;Maintain a Service Catalog&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Tip:&lt;/b&gt; Create a catalog of available services and keep it up to date. This should include some machine-readable elements such as WSDL/XSD metadata, but also some human-readable documentation. Data structures should be defined and explained.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;Rationale:&lt;/b&gt; If SOA is being seriously pursued in an organization, awareness of the services exposed by various projects is critical. A central catalog provides a single go-to place to learn about available services. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p style="margin:0in 0in 10pt"&gt;&lt;font size=3&gt;&lt;font color="#000000"&gt;&lt;font face=Calibri&gt;&lt;b style=""&gt;What If I Don’t?&lt;/b&gt; The left hand won’t know what the right hand is doing.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+WCF+Tips+%231+-+Service+Interface+Design&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!257.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!257.entry</guid><pubDate>Wed, 26 Sep 2007 03:23:51 GMT</pubDate><slash:comments>43</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!257/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!257.entry#comment</wfw:comment><dcterms:modified>2007-09-26T03:33:02Z</dcterms:modified></item><item><title>WCF Sample: Peer-to-Peer Digital Whiteboard</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!211.entry</link><description>&lt;div&gt;&lt;span style="font-size:8pt"&gt;&lt;em&gt;To read the original article with downloadable code, go to &lt;/em&gt;&lt;a href="http://www.NetfxExperts.com/wcf.Whiteboard.aspx"&gt;&lt;em&gt;http://www.NetfxExperts.com/wcf.Whiteboard.aspx&lt;/em&gt;&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;A WCF-based Digital Whiteboard sample originally appeared in Chapter 15 of &lt;i&gt;Programming Indigo&lt;/i&gt; and has been rewritten for the July CTP. Whereas the original used duplex communication and routed communication through a central server, this version uses WCF PeerChannel and requires no server.&lt;/div&gt;
&lt;p&gt;The sample is a WinForms client. Multiple parties can participate in a meeting, and there can be any number of meetings. Once you join a meeting, you can apply lines, rectangle, circles, and text to the whiteboard. You can also send chat messages to others in the meeting.
&lt;p&gt;This application does require a resolver service to be running, which all peers use to enter/leave the peer-to-peer conversation mesh. Use the custom peer resolver from the SDK sample.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+WCF+Sample%3a+Peer-to-Peer+Digital+Whiteboard&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!211.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!211.entry</guid><pubDate>Tue, 08 Aug 2006 17:35:06 GMT</pubDate><slash:comments>2</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!211/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!211.entry#comment</wfw:comment><dcterms:modified>2006-08-08T17:35:06Z</dcterms:modified></item><item><title>Design Patterns in WCF: Service Locator</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!210.entry</link><description>&lt;div&gt;&lt;em&gt;Read original article with downloadable code on &lt;/em&gt;&lt;a href="http://www.netfxexperts.com/wcf.patterns.ServiceLocator.aspx"&gt;&lt;em&gt;NetfxExperts.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt; &lt;/em&gt;&lt;/div&gt;
&lt;p&gt;The Service Locator design pattern is a service that serves as a registry of other services. With a Service Locator, clients for services can make dynamic inquiries to locate a target service instead of relying on their own local configuration.
&lt;p&gt;The simplest implementation of Service Locator might look up a service by a single characteristic, such as a name, and return its address. Far more useful is the ability to look up a service based on multiple properties and to return not just address but other connection information such as contract, binding, and security model.
&lt;p&gt;The Service Locator code example is implemented with WCF (July CTP) and allows for multiple properties of services, including those below. The list of properties can be easily extended.
&lt;ul&gt;
&lt;li&gt;environment - a deployment environment, such as 'staging' or 'production'. 
&lt;li&gt;zone - a subdivision of an environment, such as 'intranet' or 'dmz'. 
&lt;li&gt;contract - the name of the interface the service implements, such as 'IPurchasing'. 
&lt;li&gt;address - an endpoint address for the service, such as 'http://server15/purchasing/'. 
&lt;li&gt;binding - the binding profile to use to access the service, such as 'wsHttpBinding'. 
&lt;li&gt;security - the security mode to use to access the service, such as 'Windows' or 'None'. 
&lt;li&gt;reliable - whether or not reliable messaging is enabled ('True' or 'False'). &lt;/ul&gt;
&lt;p&gt;The sample stores the service information in an XML file, but it would be a simple matter to use a database or some other repository. The sample hosts the Locator Service as a Windows NT service.
&lt;div&gt;&lt;b&gt;Service Definitions&lt;/b&gt;&lt;br&gt;Servie definitions are stored in XML entries as shown below. An outer serviceDefinitions element contains n service elements. The child elements of each service element define the names and value of properties describing the service. To add new elements, simply insert additional child elements in the XML. However, be sure to keep the collection of properties consistent among all services.&lt;br&gt;&lt;br&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br&gt;&amp;lt;serviceDefinitions&amp;gt;&lt;br&gt;&lt;br&gt;  &amp;lt;service&amp;gt;&lt;br&gt;    &amp;lt;environment&amp;gt;Staging&amp;lt;/environment&amp;gt;&lt;br&gt;    &amp;lt;zone&amp;gt;Intranet&amp;lt;/zone&amp;gt;&lt;br&gt;    &amp;lt;contract&amp;gt;IInventory&amp;lt;/contract&amp;gt;&lt;br&gt;    &amp;lt;address&amp;gt;http://staging-server/Inventory/&amp;lt;/address&amp;gt;&lt;br&gt;    &amp;lt;binding&amp;gt;wsHttpBinding&amp;lt;/binding&amp;gt;&lt;br&gt;    &amp;lt;security&amp;gt;Windows&amp;lt;/security&amp;gt;&lt;br&gt;    &amp;lt;reliable&amp;gt;False&amp;lt;/reliable&amp;gt;&lt;br&gt;  &amp;lt;/service&amp;gt;&lt;br&gt;&lt;br&gt;  &amp;lt;service&amp;gt;&lt;br&gt;    &amp;lt;environment&amp;gt;Staging&amp;lt;/environment&amp;gt;&lt;br&gt;    &amp;lt;zone&amp;gt;Intranet&amp;lt;/zone&amp;gt;&lt;br&gt;    &amp;lt;contract&amp;gt;IShipping&amp;lt;/contract&amp;gt;&lt;br&gt;    &amp;lt;address&amp;gt;net.tcp://staging-server/Shipping/&amp;lt;/address&amp;gt;&lt;br&gt;    &amp;lt;binding&amp;gt;netTcpBinding&amp;lt;/binding&amp;gt;&lt;br&gt;    &amp;lt;security&amp;gt;Windows&amp;lt;/security&amp;gt;&lt;br&gt;    &amp;lt;reliable&amp;gt;True&amp;lt;/reliable&amp;gt;&lt;br&gt;  &amp;lt;/service&amp;gt;&lt;br&gt;&lt;br&gt;  &amp;lt;service&amp;gt;&lt;br&gt;    &amp;lt;environment&amp;gt;Production&amp;lt;/environment&amp;gt;&lt;br&gt;    &amp;lt;zone&amp;gt;Intranet&amp;lt;/zone&amp;gt;&lt;br&gt;    &amp;lt;contract&amp;gt;IInventory&amp;lt;/contract&amp;gt;&lt;br&gt;    &amp;lt;address&amp;gt;http://server1/Inventory/&amp;lt;/address&amp;gt;&lt;br&gt;    &amp;lt;binding&amp;gt;wsHttpBinding&amp;lt;/binding&amp;gt;&lt;br&gt;    &amp;lt;security&amp;gt;Windows&amp;lt;/security&amp;gt;&lt;br&gt;    &amp;lt;reliable&amp;gt;False&amp;lt;/reliable&amp;gt;&lt;br&gt;  &amp;lt;/service&amp;gt;&lt;br&gt;&lt;br&gt;  &amp;lt;service&amp;gt;&lt;br&gt;    &amp;lt;environment&amp;gt;Production&amp;lt;/environment&amp;gt;&lt;br&gt;    &amp;lt;zone&amp;gt;Intranet&amp;lt;/zone&amp;gt;&lt;br&gt;    &amp;lt;contract&amp;gt;IShipping&amp;lt;/contract&amp;gt;&lt;br&gt;    &amp;lt;address&amp;gt;net.tcp://server2/Shipping/&amp;lt;/address&amp;gt;&lt;br&gt;    &amp;lt;binding&amp;gt;netTcpBinding&amp;lt;/binding&amp;gt;&lt;br&gt;    &amp;lt;security&amp;gt;Windows&amp;lt;/security&amp;gt;&lt;br&gt;    &amp;lt;reliable&amp;gt;True&amp;lt;/reliable&amp;gt;&lt;br&gt;  &amp;lt;/service&amp;gt;&lt;br&gt;&lt;br&gt;&amp;lt;/serviceDefinitions&amp;gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;The Locator Service&lt;/b&gt;&lt;br&gt;&lt;/div&gt;
&lt;p&gt;The sample implements a service with two service operations: ListAllServices, and FindService.
&lt;p&gt;&lt;b&gt;ListAllServices&lt;/b&gt; returns property information for all defined services. The properties are returned as an array of ServiceProperty, a simple structure with a key (name) and value. The client can examine the returned connection properties such as address and binding to learn where and how to connect to a target service.
&lt;p&gt;&lt;b&gt;FindService&lt;/b&gt; returns information on services that match criteria specified by the caller. To specify criteria, the caller submits an array of service properties. For example, a client searching for a service in the Production environment that implements IOrderEntry would specify two service properties. (&amp;quot;Environment&amp;quot;, &amp;quot;Production&amp;quot;) and (&amp;quot;Contract&amp;quot;, &amp;quot;IOrderEntry&amp;quot;).
&lt;div&gt;&lt;b&gt;Sample Installation and Setup&lt;/b&gt;&lt;br&gt;&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Download the LocatorService.zip file and extract its contents to a folder. 
&lt;li&gt;Open LocatorService.sln in Visual Studio 2005 
&lt;li&gt;Modify the service's App.Config file to reflect the name and location of the XML file that will contain service definitions. As downloaded, this file is c:\ServiceDefinitions.xml.&lt;br&gt;&lt;br&gt;
&lt;div&gt;&amp;lt;applicationSettings&amp;gt;&lt;br&gt;  &amp;lt;LocatorService.Properties.Settings&amp;gt;&lt;br&gt;    &amp;lt;setting name=&amp;quot;ServiceDefinitions&amp;quot; serializeAs=&amp;quot;String&amp;quot;&amp;gt;&lt;br&gt;    &amp;lt;value&amp;gt;c:\\ServiceDefinitions.xml&amp;lt;/value&amp;gt;&lt;br&gt;    &amp;lt;/setting&amp;gt;&lt;br&gt;  &amp;lt;/LocatorService.Properties.Settings&amp;gt;&lt;br&gt;&amp;lt;/applicationSettings&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;
&lt;li&gt;Build the solution. 
&lt;li&gt;Install the Locator Service from a command line by navigating to the service's project output path and entering the command &lt;b&gt;installutil LocatorService.exe&lt;/b&gt;. 
&lt;li&gt;Using &lt;i&gt;Control Panel &amp;gt; Administrative Tools &amp;gt; Services &amp;gt; Services&lt;/i&gt;, start up the service and set its Startup Type to Automatic. &lt;/ol&gt;
&lt;p&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-1630591290702063730&amp;page=RSS%3a+Design+Patterns+in+WCF%3a+Service+Locator&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=davidpallmann.spaces.live.com&amp;amp;GT1=davidpallmann"&gt;</description><comments>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!210.entry#comment</comments><guid isPermaLink="true">http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!210.entry</guid><pubDate>Mon, 07 Aug 2006 22:53:07 GMT</pubDate><slash:comments>2</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://davidpallmann.spaces.live.com/blog/cns!E95EF9DC3FDB978E!210/comments/feed.rss</wfw:commentRss><wfw:comment>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!210.entry#comment</wfw:comment><dcterms:modified>2006-08-08T17:36:27Z</dcterms:modified></item><item><title>Speaking at Desert Code Camp (Tempe AZ) on May 6</title><link>http://davidpallmann.spaces.live.com/Blog/cns!E95EF9DC3FDB978E!199.entry</link><description>&lt;div&gt;The Phoenix-Tempe (AZ) area is hosting a &lt;a href="http://www.desertcodecamp.com"&gt;Desert Code Camp &lt;/a&gt;on May 6th. I'll be giving 4 presentations, 2 of them with Chris Rolon:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Service Orientation / SOA (Pallmann)&lt;/div&gt;
&lt;div&gt;Introduction to WCF (Rolon and Pallmann)&lt;/div&gt;
&lt;div&gt;WCF Design Patterns (Pallmann)&lt;/div&gt;
&lt;div&gt;WCF 