<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>WCF</title>
        <link>http://geekswithblogs.net/EltonStoneman/category/8499.aspx</link>
        <description>WCF</description>
        <language>en-GB</language>
        <copyright>EltonStoneman</copyright>
        <managingEditor>elton.stoneman@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Managing Concurrency over Service Boundaries</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/04/15/managing-concurrency-over-service-boundaries.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Managing concurrency within an application boundary can be straightforward where you own the database schema and the application's data representation. By adding an incrementing lock sequence to tables and holding the current sequence in entity objects, you can implement optimistic locking at the database level without a significant performance hit. At the service level, the situation is more complicated. Even where the database schema can be extended, you wouldn't want the internals of concurrency management to be exposed in service contracts, so the lock sequence approach isn't suitable. &lt;/p&gt;
&lt;p&gt;An alternative pattern is to compute a data signature representing the retrieved state of an entity at the service level, and flow the signature alongside the entity in Get services. On Update calls, the original data signature is passed back and compared to the current signature of the data; if they differ then there's been a concurrency violation and the update fails. The signature can be passed as a SOAP header across the wire so it's not part of the contract and the optimistic locking strategy is transparent to consumers. &lt;/p&gt;
&lt;p&gt;The level of transparency will depend on the consumer, as it needs to retrieve the signature from the Get call, retain it, and pass it back on the Update call. In WCF the DataContract versioning mechanism can be used to extract the signature from the header and retain it in the &lt;em&gt;ExtensionData&lt;/em&gt; property of &lt;strong&gt;IExtensibleDataObject&lt;/strong&gt;. The contents of the &lt;em&gt;ExtensionData&lt;/em&gt; property are not directly accessible, so if the same &lt;strong&gt;DataContract&lt;/strong&gt; is used on the Get and the Update, and the signature management is done through WCF extension points, then concurrency control is transparent to users. &lt;/p&gt;
&lt;p&gt;I've worked through a WCF implementation for this pattern on MSDN Code Gallery here: &lt;a href="http://code.msdn.microsoft.com/WCFOptimisticLocking"&gt;Optimistic Locking over WCF&lt;/a&gt;. The sample uses a WCF behavior on the server side to compute a data signature (as a hash of the serializable object – generating a deterministic GUID from the XML string) and adds it to outgoing message headers for all services which return a &lt;strong&gt;DataContract&lt;/strong&gt; object. On the consumer side, a parallel behaviour extracts the data signature from the header and adds it to &lt;em&gt;ExtensionData&lt;/em&gt;, by appending it to the XML payload and using the standard &lt;strong&gt;DataContractSerializer&lt;/strong&gt; to extract it. &lt;/p&gt;
&lt;p&gt;The update service checks the data signature passed in the call with the current signature of the object and throws a known &lt;strong&gt;FaultException&lt;/strong&gt; if there's been a concurrency violation, which the WCF client can catch and react to: &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/041509_2214_ManagingCon1.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Sixeyed.OptimisticLockingSample &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The sample solution consists of four projects providing a SQL database for Customer entities, WCF Get and Update services, a WCF client and the ServiceModel library which contains the data signature behaviors. &lt;strong&gt;DataSignatureServiceBehavior&lt;/strong&gt; adds a dispatch message formatter to each service operation, which computes the hash for any &lt;strong&gt;DataContract&lt;/strong&gt; objects being returned, and adds it to the message headers. &lt;strong&gt;DataSignatureEndpointBehavior&lt;/strong&gt; on the client adds a client message formatter to each endpoint operation, which extracts the hash from incoming calls, stores it in &lt;em&gt;ExtensionData&lt;/em&gt; and adds it back to the header on outgoing calls.  &lt;/p&gt;
&lt;p&gt;Concurrency checking is done on the server side in the Update call, by comparing the given data signature to the signature from the current object state: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; dataSignature = &lt;span style="color: rgb(43, 145, 175);"&gt;DataSignature&lt;/span&gt;.Current; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (dataSignature == &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt;.Empty) &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: green;"&gt;//this is an update method, so no data signature to  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: green;"&gt;//compare against is an exception: &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;throw&lt;/span&gt; 			&lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;FaultException&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;NoDataSignature&lt;/span&gt;&amp;gt;(&lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;NoDataSignature&lt;/span&gt;()); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt; currentState = CustomerEntityService.Load(customer); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; currentDataSignature = &lt;span style="color: rgb(43, 145, 175);"&gt;DataSignature&lt;/span&gt;.Sign(currentState); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;//if the data signatures match then update: &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (currentDataSignature == dataSignature) &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    CustomerEntityService.Update(customer); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: blue; font-family: Courier New; font-size: 10pt;"&gt;else &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: green;"&gt;//otherwise, throw concurrency violation exception: &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;throw&lt;/span&gt; 			&lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;FaultException&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;ConcurrencyViolation&lt;/span&gt;&amp;gt;(&lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;ConcurrencyViolation&lt;/span&gt;()); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;A limitation of the sample is the use of &lt;strong&gt;IExtensibleDataObject&lt;/strong&gt; to store the data signature at the client side. Although this is fully functional and allows a completely generic solution, it relies on reflection to extract the data signature and add it to the message headers for the update call, which is &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2009/04/03/accessing-extended-data-from-iextensibledataobject.aspx"&gt;a brittle option.&lt;/a&gt; Where you have greater control over the client, you can use a custom solution which will be more suitable – e.g. creating and implementing an &lt;strong&gt;IDataSignedEntity&lt;/strong&gt; interface, or if consuming the services in BizTalk, by using context properties. &lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=131239"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=131239" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/131239.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/04/15/managing-concurrency-over-service-boundaries.aspx</guid>
            <pubDate>Thu, 16 Apr 2009 04:15:04 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/131239.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/04/15/managing-concurrency-over-service-boundaries.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/131239.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Applying WCF Message Formatters Using Configuration</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/04/04/applying-wcf-message-formatters-using-configuration.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The WCF message formatter interfaces &lt;strong&gt;IClientMessageFormatter&lt;/strong&gt; and &lt;strong&gt;IDispatchMessageFormatter&lt;/strong&gt; let you intercept WCF messages on the client or service side at the point of serialization and deserialization. They're useful injection points as they give you access to the input or output parameter values of the service call, and to the incoming or outgoing WCF Message object. The formatters allow you to inspect or modify the message content or headers, using the call parameters to drive your logic. &lt;/p&gt;
&lt;p&gt;Formatters need to be applied as operation behaviors, so there's no direct way to add them via binding configurations – typically they're added programmatically to the client channel, or to the service as attributes on the operation contract. But if your requirements are to add the same formatter to every operation and you want the flexibility of the configuration model, you can add formatters by piggybacking onto other behaviors which can be specified in configuration – &lt;strong&gt;IEndpointBehavior&lt;/strong&gt; on the client and &lt;strong&gt;IServiceBehavior&lt;/strong&gt; on the service: &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/040409_2115_ApplyingWCF1.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;(more detail on the data signature project in a future post). &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Client Side&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;&lt;em&gt;DataSignatureOperationBehavior.ApplyClientBehavior&lt;/em&gt; adds a &lt;strong&gt;DataSignatureClientFormatter&lt;/strong&gt; to a single client operation: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; 			&lt;span style="color: blue;"&gt;void&lt;/span&gt; ApplyClientBehavior(&lt;span style="color: rgb(43, 145, 175);"&gt;OperationDescription&lt;/span&gt; operationDescription, &lt;span style="color: rgb(43, 145, 175);"&gt;ClientOperation&lt;/span&gt; clientOperation) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;DataSignatureClientFormatter&lt;/span&gt; formatter = &lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;DataSignatureClientFormatter&lt;/span&gt;(); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    formatter.OrginalFormatter = clientOperation.Formatter; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    clientOperation.Formatter = formatter;             &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Adding the formatter to one operation cannot be specified in client-side configuration. However the DataSignatureOperationBehavior can be added to every client operation in an endpoint using &lt;em&gt;IEndpointBehavior.ApplyClientBehavior&lt;/em&gt;. &lt;strong&gt;DataSignatureEndpointBehavior&lt;/strong&gt; adds the client formatter to every operation, by using the existing operation behavior: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; 			&lt;span style="color: blue;"&gt;void&lt;/span&gt; ApplyClientBehavior(&lt;span style="color: rgb(43, 145, 175);"&gt;ServiceEndpoint&lt;/span&gt; endpoint, &lt;span style="color: rgb(43, 145, 175);"&gt;ClientRuntime&lt;/span&gt; clientRuntime) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;OperationDescription&lt;/span&gt; operation &lt;span style="color: blue;"&gt;in&lt;/span&gt; endpoint.Contract.Operations) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;        operation.Behaviors.Add(&lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;DataSignatureOperationBehavior&lt;/span&gt;()); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The endpoint behavior is exposed in the client configuration mode by extending &lt;strong&gt;BehaviorExtensionElement&lt;/strong&gt;, so the DataSignatureFormatter can be added to every operation in an endpoint by configuring the DataSignatureEndpointBehavior: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;client&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;endpoint&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;address&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://localhost/x.y.z.svc&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;binding&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;basicHttpBinding&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;BasicHttpBinding_ICustomerService&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;dataSignatureBehavior&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;contract&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;CustomerService.ICustomerService&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;BasicHttpBinding_ICustomerService&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;client&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behavior&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;dataSignatureBehavior&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;dataSignatureBehavior&lt;/span&gt;&lt;span style="color: blue;"&gt; /&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behavior&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;extensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviorExtensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;add &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;dataSignatureBehavior&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.OptimisticLockingSample.ServiceModel.Behaviors.DataSignatureEndpointBehavior…/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviorExtensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;extensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Service Side&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;The service stack is the parallel of the client side – &lt;strong&gt;DataSignatureDispatchFormatter&lt;/strong&gt; is added via an operation behavior using &lt;em&gt;DataSignatureOperationBehavior.ApplyDispatchBehavior&lt;/em&gt;: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; 			&lt;span style="color: blue;"&gt;void&lt;/span&gt; ApplyDispatchBehavior(&lt;span style="color: rgb(43, 145, 175);"&gt;OperationDescription&lt;/span&gt; operationDescription, &lt;span style="color: rgb(43, 145, 175);"&gt;DispatchOperation&lt;/span&gt; dispatchOperation) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;DataSignatureDispatchFormatter&lt;/span&gt; formatter = &lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;DataSignatureDispatchFormatter&lt;/span&gt;(); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    formatter.OrginalFormatter = dispatchOperation.Formatter; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    dispatchOperation.Formatter = formatter;  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;Again this behavior is not available in the service configuration model, but it can be added to every operation in the service using &lt;em&gt;IServiceBehavior.ApplyDispatchBehavior&lt;/em&gt;, as is done in &lt;strong&gt;DataSignatureServiceBehavior&lt;/strong&gt;: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; 			&lt;span style="color: blue;"&gt;void&lt;/span&gt; ApplyDispatchBehavior(&lt;span style="color: rgb(43, 145, 175);"&gt;ServiceDescription&lt;/span&gt; serviceDescription, System.ServiceModel.&lt;span style="color: rgb(43, 145, 175);"&gt;ServiceHostBase&lt;/span&gt; serviceHostBase) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;ServiceEndpoint&lt;/span&gt; endpoint &lt;span style="color: blue;"&gt;in&lt;/span&gt; serviceDescription.Endpoints) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;OperationDescription&lt;/span&gt; operation &lt;span style="color: blue;"&gt;in&lt;/span&gt; endpoint.Contract.Operations) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;        { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;            operation.Behaviors.Add(&lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;DataSignatureOperationBehavior&lt;/span&gt;()); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;        } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This behavior also extends BehaviorExtensionElement so it can be configured, adding the dispatch formatter will be added to every operation in the service: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;services&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;service&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;dataSignatureBehavior&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.OptimisticLockingSample.Services.CustomerService&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;endpoint&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;address&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;""&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;binding&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;basicHttpBinding&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;contract&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.OptimisticLockingSample.Services.ICustomerService&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;bindingNamespace&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://Sixeyed.OptimisticLockingSample/2009&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;service&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;services&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behavior&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt; dataSignatureBehavior&lt;/span&gt; "&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceMetadata&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;httpGetEnabled&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;true&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceDebug&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;true&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;dataSignatureBehavior&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behavior&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;extensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviorExtensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;add &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;dataSignatureBehavior&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.OptimisticLockingSample.ServiceModel.Behaviors.DataSignatureServiceBehavior…/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviorExtensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;extensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;Additionally, the DataSignatureOperationBehavior extends Attribute, so for finer-grained control the declarative approach is available using the same stack. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130746"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130746" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/130746.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/04/04/applying-wcf-message-formatters-using-configuration.aspx</guid>
            <pubDate>Sun, 05 Apr 2009 03:15:09 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/130746.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/04/04/applying-wcf-message-formatters-using-configuration.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/130746.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Accessing Extended Data from IExtensibleDataObject</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/04/03/accessing-extended-data-from-iextensibledataobject.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;DataContract&lt;/strong&gt; classes in WCF can be declared as implementing &lt;strong&gt;IExtensibleDataObject&lt;/strong&gt; to provide in-built support for schema versioning. Any data contracts created through &lt;em&gt;svcutil&lt;/em&gt; or &lt;em&gt;Add Service Reference&lt;/em&gt; implement the interface, and it's good practice to implement it for any custom &lt;strong&gt;DataContract&lt;/strong&gt; classes you write. On deserializing, elements which are not declared in the data contract are extracted by the &lt;strong&gt;DataContractSerializer&lt;/strong&gt; and added to the &lt;strong&gt;ExtensionDataObject&lt;/strong&gt; property, so unexpected data is not lost (see &lt;a href="http://bloggingabout.net/blogs/vagif/archive/2009/03/29/iextensibledataobject-is-not-only-for-backward-compatibility.aspx"&gt;Vagif Abilov's blog post on backwards compatibility with IExtensibleDataObject&lt;/a&gt;). &lt;/p&gt;
&lt;p&gt;Internally, the &lt;strong&gt;ExtensionDataMember&lt;/strong&gt; holds a convoluted key-value collection of the unrecognised data members. If you want to inspect the contents of the collection it's a fiddly process as the members are non-public, and the types and interfaces of the members (&lt;strong&gt;ExtensionDataMember&lt;/strong&gt; and &lt;strong&gt;IDataNode&lt;/strong&gt;) are also non-public. The code below allows you to extract the value of an &lt;strong&gt;ExtensionDataMember&lt;/strong&gt; given its name: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; 			&lt;span style="color: blue;"&gt;object&lt;/span&gt; GetExtensionDataMemberValue(&lt;span style="color: rgb(43, 145, 175);"&gt;IExtensibleDataObject&lt;/span&gt; extensibleObject, &lt;span style="color: blue;"&gt;string&lt;/span&gt; dataMemberName) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;object&lt;/span&gt; innerValue = &lt;span style="color: blue;"&gt;null&lt;/span&gt;; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;PropertyInfo&lt;/span&gt; membersProperty = &lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;ExtensionDataObject&lt;/span&gt;).GetProperty(&lt;span style="color: rgb(163, 21, 21);"&gt;"Members"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags&lt;/span&gt;.NonPublic | &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags&lt;/span&gt;.Instance); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;IList&lt;/span&gt; members = (&lt;span style="color: rgb(43, 145, 175);"&gt;IList&lt;/span&gt;)membersProperty.GetValue(extensibleObject.ExtensionData, &lt;span style="color: blue;"&gt;null&lt;/span&gt;); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: blue;"&gt;object&lt;/span&gt; member &lt;span style="color: blue;"&gt;in&lt;/span&gt; members) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;PropertyInfo&lt;/span&gt; nameProperty = member.GetType().GetProperty(&lt;span style="color: rgb(163, 21, 21);"&gt;"Name"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags&lt;/span&gt;.NonPublic | &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags&lt;/span&gt;.Instance); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;string&lt;/span&gt; name = (&lt;span style="color: blue;"&gt;string&lt;/span&gt;) nameProperty.GetValue(member, &lt;span style="color: blue;"&gt;null&lt;/span&gt;); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;if&lt;/span&gt; (name == dataMemberName) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;        { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;PropertyInfo&lt;/span&gt; valueProperty = member.GetType().GetProperty(&lt;span style="color: rgb(163, 21, 21);"&gt;"Value"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags&lt;/span&gt;.NonPublic | &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags&lt;/span&gt;.Instance); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;object&lt;/span&gt; value = valueProperty.GetValue(member, &lt;span style="color: blue;"&gt;null&lt;/span&gt;); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;PropertyInfo&lt;/span&gt; innerValueProperty = value.GetType().GetProperty(&lt;span style="color: rgb(163, 21, 21);"&gt;"Value"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags&lt;/span&gt;.Public | &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags&lt;/span&gt;.Instance); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;            innerValue = innerValueProperty.GetValue(value, &lt;span style="color: blue;"&gt;null&lt;/span&gt;); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;break&lt;/span&gt;; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;        } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;    } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;return&lt;/span&gt; innerValue; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;Obviously this is fragile and isn't appropriate for production solutions, but it can be useful for unit testing or debugging WCF calls, or when you want to confirm the effects of having data contracts which are out of sync between the service and the consumer. Similar code could be used to get the count of extended data members to identify if the &lt;strong&gt;DataContract&lt;/strong&gt; schema is not the correct version, and interestingly, the &lt;em&gt;value&lt;/em&gt; and &lt;em&gt;innerValue&lt;/em&gt; properties are writeable, so you could update the contents of the unrecognised members. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130724"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130724" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/130724.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/04/03/accessing-extended-data-from-iextensibledataobject.aspx</guid>
            <pubDate>Fri, 03 Apr 2009 23:51:08 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/130724.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/04/03/accessing-extended-data-from-iextensibledataobject.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/130724.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Using WCF-Custom Bindings in Dynamic Ports</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/03/06/using-wcf-custom-bindings-in-dynamic-ports.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;BizTalk 2006 R2 ships with WCF adapters and pre-configured settings for common bindings - &lt;strong&gt;basicHttp&lt;/strong&gt; and &lt;strong&gt;wsHttp&lt;/strong&gt; being typically used for SOAP messaging. With a static port you can use the WCF-Custom adapter, select an existing binding and configure it further in the UI, with the full set of binding options available to you: &lt;/p&gt;
&lt;p&gt; 		&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030609_1739_UsingWCFCus1.jpg" alt="" style="width: 446px; height: 565px;" /&gt; 	&lt;/p&gt;
&lt;p&gt;Here I'm using &lt;strong&gt;basicHttp&lt;/strong&gt;, but I've configured the &lt;em&gt;maxReceivedMessageSize&lt;/em&gt;, &lt;em&gt;sendTimeout&lt;/em&gt; and &lt;em&gt;transferMode&lt;/em&gt; settings to allow us to call long-running WCF services which return large responses. &lt;/p&gt;
&lt;p&gt;In a dynamic port, you're limited to the settings you can configure, as the &lt;a href="http://msdn.microsoft.com/en-us/library/bb245991.aspx"&gt;WCF Adapter Property Schema&lt;/a&gt; doesn't contain the full set of binding properties. You can set the &lt;em&gt;sendTimeout&lt;/em&gt; and &lt;em&gt;maxReceivedMessageSize&lt;/em&gt; on an outgoing message using code: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;port(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-BasicHttp";  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;requestMessage(WCF.MaxReceivedMessageSize) = 104857600;  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;requestMessage(WCF.SendTimeout) = "00:10:00";  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;- but there's no way to access less common properties like &lt;em&gt;transferMode&lt;/em&gt; if you're using this approach. Originally this is how we were configuring our outgoing messages, using SSO to store the values used for the binding properties (see &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2009/02/25/receiving-large-wcf-response-messages-in-esb-guidance.aspx"&gt;Receiving large WCF response messages in ESB Guidance&lt;/a&gt;), but we soon ran into an issue with one of the BizTalk servers running out of memory when attempting to process a large WCF response message: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;System.InsufficientMemoryException: Failed to allocate a managed memory buffer of 104857600 bytes. The amount of available memory may be low. ---&amp;gt; System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;   at System.ServiceModel.Diagnostics.Utility.AllocateByteArray(Int32 size)  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For &lt;strong&gt;basicHttp&lt;/strong&gt;, the &lt;em&gt;transferMode&lt;/em&gt; setting allows you to specify that messages should be streamed (one way or both ways), or buffered - the default is buffered, so when we receive the response message, although it will be streamed in the BizTalk stack, it is completely loaded into memory by the WCF stack. Note that WCF is trying to allocate the full value specified in &lt;em&gt;maxReceivedMessageSize&lt;/em&gt; – 100 Mb – even though we've set this as a practical maximum, and the actual incoming message was half that size. &lt;/p&gt;
&lt;p&gt;To remedy it, I've switched to using the WCF-Custom transport, and specifying &lt;strong&gt;basicHttp&lt;/strong&gt; with my additional settings in the &lt;em&gt;BindingConfiguration&lt;/em&gt; property: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;port(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-Custom"; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;requestMessage(WCF.BindingType) =  "basicHttpBinding"; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;requestMessage(WCF.BindingConfiguration) =  "&amp;lt;binding name=\"basicHttpBinding\" sendTimeout=\"00:10:00\" maxReceivedMessageSize=\"104857600\" /&amp;gt;"; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;The &lt;em&gt;BindingType&lt;/em&gt; needs to be specified in addition to the configuration. For the &lt;em&gt;BindingConfiguration&lt;/em&gt; value, the Properties page for a static WCF-Custom port allows you to export the settings, so you can configure it in the UI and then save the XML representation, rather than coding it all by hand. &lt;/p&gt;
&lt;p&gt;By shifting the &lt;em&gt;BindingConfiguration&lt;/em&gt; value to the SSO config store, we'll have the full range of WCF configuration available to change at run-time, so a switch to using &lt;strong&gt;wsHttp&lt;/strong&gt; or &lt;strong&gt;netTcp&lt;/strong&gt; bindings is just a setting change using the &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/06/29/sso-config-tool.aspx"&gt;SSO Config Tool&lt;/a&gt;, and a change to the endpoint address (which we configure in UDDI in this case). Originally I wanted finer control over what could be configured, so we could limit changes to a known set of properties. But having tried this approach I prefer it – it means switching bindings and adding or changing any settings can easily be done without modifying the solution – and I'll be recommending it as best practice. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129884"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129884" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/129884.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/03/06/using-wcf-custom-bindings-in-dynamic-ports.aspx</guid>
            <pubDate>Fri, 06 Mar 2009 23:38:49 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/129884.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/03/06/using-wcf-custom-bindings-in-dynamic-ports.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/129884.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Using the WCF SQL Adapter in .NET: Executing SQL Statements</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/03/04/using-the-wcf-sql-adapter-in-.net-executing-sql-statements.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Following on from my post on &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2009/03/02/using-the-wcf-sql-adapter-in-.net-calling-stored-procedures.aspx"&gt;Using the WCF SQL Adapter in .NET: Calling Stored Procedures&lt;/a&gt; (see that post for download and installation instructions for the WCF LOB adapter pack), this one looks at using the adapter to execute SQL statements on database objects. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Walkthrough: Executing SQL Statements&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Add Adapter Service Reference&lt;/em&gt; generates separate entity and client classes for each table you select, and separate request and response classes for each table operation. To generate proxies for executing SQL statements against a table, choose the operations from the Tables view of the hierarchy: &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030409_1922_UsingtheWCF1.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;Selecting the Insert and Select operations against the BikeTypes table will generate the following class structure: &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030409_1922_UsingtheWCF2.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;The client for connecting to SQL Server is a standard WCF client class, inheriting from &lt;strong&gt;ClientBase&lt;/strong&gt; and specifying the &lt;strong&gt;ServiceContract&lt;/strong&gt; as its channel – in this case the interface is &lt;strong&gt;TableOp_dbo_BikeTypes&lt;/strong&gt; which has operation contracts representing the Insert and Select statements. The entity representing the database table implements &lt;strong&gt;IExtensibleDataObject&lt;/strong&gt; and provides &lt;strong&gt;DataMember&lt;/strong&gt;-flagged properties for each table column; an array of entities is used as the input for the Insert operation, and the return for the Select operation (wrapping the underlying use of generated Request and Response classes). &lt;/p&gt;
&lt;p&gt;The Request and Response classes are flagged with &lt;strong&gt;MessageContract&lt;/strong&gt; attributes. Message contracts are less commonly seen than &lt;strong&gt;DataContract&lt;/strong&gt; and &lt;strong&gt;ServiceContract&lt;/strong&gt;, but they allow you finer control over the messages sent and received by the adapter, including the ability to specify whether data is to be serialized in the header or body of the message (see &lt;a href="http://msdn.microsoft.com/en-us/library/ms730255.aspx"&gt;Using Message Contracts&lt;/a&gt;). In the generated classes, &lt;strong&gt;MessageContract&lt;/strong&gt; is used to specify the wrapper name and namespace, which puts the message payload within a defined element in the SOAP body. The following attribute: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;[System.ServiceModel.&lt;span style="color: rgb(43, 145, 175);"&gt;MessageContractAttribute&lt;/span&gt;(WrapperName=&lt;span style="color: rgb(163, 21, 21);"&gt;"Select"&lt;/span&gt;, WrapperNamespace=&lt;span style="color: rgb(163, 21, 21);"&gt;"http://schemas.microsoft.com/Sql/2008/05/TableOp/dbo/BikeTypes"&lt;/span&gt;, IsWrapped=&lt;span style="color: blue;"&gt;true&lt;/span&gt;)]&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;- generates a SOAP message for the &lt;strong&gt;SelectRequest&lt;/strong&gt; class which looks like this: &lt;/p&gt;
&lt;p style="margin-left: 24pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;s:Envelope &lt;/span&gt;&lt;span style="color: red;"&gt;xmlns:a&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;strong&gt;http://www.w3.org/2005/08/addressing&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;" &lt;/span&gt;&lt;span style="color: red;"&gt;xmlns:s&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;strong&gt;http://www.w3.org/2003/05/soap-envelope&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 37pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;s:Header&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 49pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;a:Action s:mustUnderstand&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;span style="color: blue;"&gt;"&amp;gt;&lt;/span&gt;&lt;strong&gt;TableOp/Select/dbo/BikeTypes&lt;/strong&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;a:Action&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 49pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;a:MessageID&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;strong&gt;urn:uuid:9a5fe359-e988-4504-96a9-b9b721d00502&lt;/strong&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;a:MessageID&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 49pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;a:ReplyTo&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 61pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;a:Address&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;strong&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/strong&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;a:Address&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 49pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;a:ReplyTo&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 37pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;s:Header&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 37pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;s:Body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 49pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Select &lt;/span&gt;&lt;span style="color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;strong&gt;http://schemas.microsoft.com/Sql/2008/05/TableOp/dbo/BikeTypes&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 61pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Columns&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;strong&gt;*&lt;/strong&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Columns&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 61pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Query&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;strong&gt;WHERE BikeTypeCode LIKE '%R%'&lt;/strong&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Query&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 49pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Select&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 37pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;s:Body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 24pt;"&gt;&lt;span style="font-family: Verdana; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;s:Envelope&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;Note that the SOAP action is the Node Id for the operation from &lt;em&gt;Add Adapter Service Reference&lt;/em&gt;. The request message contains Columns and Query elements, which are used in the call to refine the size and content of the resultset. In code you specify the &lt;em&gt;Columns&lt;/em&gt; property with "*" to return all, or a comma-separated list of column names (which should be listed in the same order as defined in the table). &lt;em&gt;Query&lt;/em&gt; can be null, empty or contain a WHERE clause to restrict the results: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;TableOp_dbo_BikeTypesClient&lt;/span&gt; client = &lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;TableOp_dbo_BikeTypesClient&lt;/span&gt;(); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;client.Open(); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;BikeTypes&lt;/span&gt;[] allBikeTypes = client.Select(&lt;span style="color: rgb(163, 21, 21);"&gt;"*"&lt;/span&gt;, &lt;span style="color: blue;"&gt;null&lt;/span&gt;); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;BikeTypes&lt;/span&gt;[] bikeTypeDescriptions = client.Select(&lt;span style="color: rgb(163, 21, 21);"&gt;"BikeTypeDescription"&lt;/span&gt;, &lt;span style="color: blue;"&gt;string&lt;/span&gt;.Empty); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;BikeTypes&lt;/span&gt;[] likeRBikeTypes = client.Select(&lt;span style="color: rgb(163, 21, 21);"&gt;"*"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"WHERE BikeTypeCode LIKE '%R%'"&lt;/span&gt;);&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;A populated &lt;em&gt;Query&lt;/em&gt; property will limit the number of items returned. A populated &lt;em&gt;Columns&lt;/em&gt; property will limit the number of populated elements in the response, so the typed object will have null values for any unmapped columns. &lt;/p&gt;
&lt;p&gt;For the insert, you pass an array of populated entities to the call: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;BikeTypes&lt;/span&gt;&amp;gt; bikeTypes = &lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;BikeTypes&lt;/span&gt;&amp;gt;(); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;bikeTypes.Add(&lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;BikeTypes&lt;/span&gt;()); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;bikeTypes[0].BikeTypeCode = &lt;span style="color: rgb(163, 21, 21);"&gt;"NEW"&lt;/span&gt;; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;bikeTypes[0].BikeTypeDescription = &lt;span style="color: rgb(163, 21, 21);"&gt;"New Type"&lt;/span&gt;; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;TableOp_dbo_BikeTypesClient&lt;/span&gt; client = &lt;span style="color: blue;"&gt;new&lt;/span&gt; 			&lt;span style="color: rgb(43, 145, 175);"&gt;TableOp_dbo_BikeTypesClient&lt;/span&gt;(); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;client.Open(); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;client.Insert(bikeTypes.ToArray()); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you want to write identity values for tables which have an identity column, you can specify &lt;em&gt;AllowIdentityInsert&lt;/em&gt; in the binding configuration. Otherwise, any specified columns have the value from the entity inserted; null values have NULL inserted. The return contains an array of &lt;strong&gt;long&lt;/strong&gt; values containing the identity of the inserted rows – unless the table does not have an identity column, in which case the return is null. &lt;/p&gt;
&lt;p&gt;Similarly the adapter can generate request and response classes for Update and Delete statements, which follow the same pattern. The generated stack has the same benefits as with the stored procedure calls – the code is very light and it uses the standard WCF stack, so if you'd rather generate or hand-craft your own connections, that's a definite option. I'll explore it in a later post. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129839"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129839" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/129839.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/03/04/using-the-wcf-sql-adapter-in-.net-executing-sql-statements.aspx</guid>
            <pubDate>Thu, 05 Mar 2009 01:21:35 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/129839.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/03/04/using-the-wcf-sql-adapter-in-.net-executing-sql-statements.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/129839.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Using the WCF SQL Adapter in .NET: Calling Stored Procedures</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/03/02/using-the-wcf-sql-adapter-in-.net-calling-stored-procedures.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The Adapter Pack 2.0 for BizTalk has been &lt;a href="http://blogs.msdn.com/adapters/archive/2009/02/20/adapter-pack-2-0-beta-released.aspx"&gt;released in public beta recently&lt;/a&gt;, and among the WCF Line Of Business adapters it contains the WCF SQL adapter. This exposes SQL Server connections as WCF service endpoints, and lets you connect to a SQL Server source using the standard ServiceModel stack. The adapter pack will be released under the BizTalk brand, but the adapters themselves are not limited to BizTalk – the WCF SQL adapter can be used natively in .NET code. &lt;/p&gt;
&lt;p&gt;This is a brief walkthrough covering the SQL Adapter for executing stored procedures, and I'll be covering SQL statements in a subsequent post. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Installation &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Installation of the Adapter Pack is straightforward – you'll need .NET 3.5 Service Pack 1 with the latest hotfixes applied, and you'll need to install the WCF LOB Adapter SDK and then the BizTalk Adapter Pack 2.0 Evaluation (the beta version is limited to 120-day use). Note, you do not need to have BizTalk installed, and the tooling to support the WCF LOB adapters runs under Visual Studio 2008 as well as 2005. Help files for all the adapters are included, and although in pre-release form they are detailed and thorough. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Walkthrough: Consuming a Stored Procedure&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;The Adapter Pack adds a new context menu to code projects in Visual Studio – &lt;em&gt;Add Adapter Service Reference&lt;/em&gt;. Run this and you're given a generic form for configuring your WCF LOB adapter. Choose &lt;strong&gt;sqlBinding&lt;/strong&gt; to set up a WCF SQL connection: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030209_1842_UsingtheWCF1.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;Click Configure and you specify the connection configuration that will be used to build the binding. In the case of the WCF SQL adapter, you need to specify: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Client Credential Type (Windows for integrated authentication); &lt;/li&gt;
    &lt;li&gt;Server (database server name); &lt;/li&gt;
    &lt;li&gt;Instance (SQL instance name, if configured); &lt;/li&gt;
    &lt;li&gt;Initial catalog (the database to connect to). &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This will build you a URI of the form: &lt;strong&gt;mssql://&amp;lt;server&amp;gt;/&amp;lt;instance&amp;gt;/&amp;lt;initialCatalog&amp;gt;?&lt;/strong&gt; – with the ending question mark used to separate the core connection details from any configuration options. &lt;/p&gt;
&lt;p&gt;Click Connect and you have the option to generate a Client binding, for making outbound requests to SQL Server (executing SQL statements, stored procedures etc.), or a Service binding which will react to inbound calls from SQL Server (for Query Notification or polling). Choose Client and the category view will be populated with a hierarchy of database objects which can be generated as WCF client proxies: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030209_1842_UsingtheWCF2.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Generated Code &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;For stored procedure calls, the adapter can create generic proxies for weakly-typed calls returning populated DataSets, or strongly-typed calls which will generate entities representing the return from the call. In this case I've selected a Strongly-Typed Stored Procedure called GetManufacturer; add the selection and with the default options the adapter generates two items: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;App.config – containing the WCF binding configuration; &lt;/li&gt;
    &lt;li&gt;SqlAdapterBindingClient.cs – containing the generated entity types and proxy classes. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The full binding configuration for the SQL adapter looks like this: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;bindings&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;sqlBinding&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;binding&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SqlAdapterBinding&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;closeTimeout&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;00:01:00&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;openTimeout&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;00:01:00&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;receiveTimeout&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;00:10:00&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;sendTimeout&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;00:01:00&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;maxConnectionPoolSize&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;100&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;encrypt&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;workstationId&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;""&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;useAmbientTransaction&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;true&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;batchSize&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;20&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;polledDataAvailableStatement&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;""&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;pollingStatement&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;pollingIntervalInSeconds&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;30&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;pollWhileDataFound&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;notificationStatement&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;notifyOnListenerStart&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;true&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;enableBizTalkCompatibilityMode&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;true&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;chunkSize&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;4194304&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;inboundOperationType&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Polling&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;useDatabaseNameInXsdNamespace&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;allowIdentityInsert&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;enablePerformanceCounters&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;xmlStoredProcedureRootNodeName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;""&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;xmlStoredProcedureRootNodeNamespace&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;""&lt;span style="color: blue;"&gt; /&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;sqlBinding&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;bindings&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;client&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;endpoint&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;address&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;mssql://x/y/z?&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;binding&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;sqlBinding&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SqlAdapterBinding&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;contract&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TypedProcedures_dbo&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SqlAdapterBinding_TypedProcedures_dbo&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;client&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;- note that the binding contains some familiar WCF settings (sendTimeout, receiveTimeout), but the majority are SQL Server specific connection options. The client element specifies the contract as &lt;strong&gt;TypedProcedures_dbo&lt;/strong&gt;, the ServiceContract interface generated by the adapter, which has a single OperationContract defined: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;GetManufacturerResponse&lt;/span&gt; GetManufacturer(&lt;span style="color: rgb(43, 145, 175);"&gt;GetManufacturerRequest&lt;/span&gt; request); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The proxy code for the client is all generated, so to invoke the stored procedure in your own code it's a familiar case of instantiating the client and calling the service, and of course you have full IntelliSense on the entity representing the resultset: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030209_1842_UsingtheWCF3.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;It's the content of the generated code that's interesting. The service, request, response and entity objects here are contained in 166 lines of generated code. The entity object is just a plain DTO-style class which implements &lt;strong&gt;IExtensibleDataObject&lt;/strong&gt; to allow access to any returned data that hasn't been mapped, and has a DataContract attribute with the schema name representing the stored procedure. The mapping between the entity properties and the returned columns is done with standard System.Runtime.Serialization attributes, so the ManufacturerId column is represented as: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;        [System.Runtime.Serialization.&lt;span style="color: rgb(43, 145, 175);"&gt;DataMemberAttribute&lt;/span&gt;()] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;public&lt;/span&gt; System.&lt;span style="color: rgb(43, 145, 175);"&gt;Nullable&lt;/span&gt;&amp;lt;&lt;span style="color: blue;"&gt;short&lt;/span&gt;&amp;gt; ManufacturerId { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;return&lt;/span&gt; 			&lt;span style="color: blue;"&gt;this&lt;/span&gt;.ManufacturerIdField; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;            } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;set&lt;/span&gt; { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; 			&lt;span style="color: blue;"&gt;this&lt;/span&gt;.ManufacturerIdField = &lt;span style="color: blue;"&gt;value&lt;/span&gt;; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;            } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;        } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;- note that this is an optional field in the database table, so it's generated as nullable in the entity. No other flags or code are used to map data, so the WCF SQL adapter is effectively deserializing the resultset from the stored procedure call straight into the DataContract. &lt;/p&gt;
&lt;p&gt;The generated code works well and is cleanly produced, but it has a few quirks you may not be happy with. A typed client class is generated for each individual procedure, whereas you might want them grouped into a single class which represents the full suite; and the class names are a bit cumbersome ("StoredProcedureResultSet0", "TypedProcedures_dboClient"). However, the code needed to actually connect to SQL through WCF and map the response is so simple that it's a straightforward task to generate your own code from custom templates. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Potential Usage &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;After an initial look, the WCF SQL adapter seems to be an attractive option for generating and powering the data access layer of a .NET application, entirely apart from its primary purpose as a BizTalk adapter. It repositions data access as a service call and uses the standard WCF mechanisms of ServiceContract and DataContract for information exchange. Assuming other data providers follow suit, or other WCF-database adapters follow from the community, it's a nice way of isolating your application from the physical database, so swapping to MySQL or Oracle could become a simple matter of changing your WCF binding. &lt;/p&gt;
&lt;p&gt;It'll be interesting to see the licensing of the WCF LOB adapters from Microsoft. Currently the availability of a comprehensive suite of adapters is being positioned as one of the attractions of BizTalk as the Integration Server, compared to WF+WCF+Dublin as the Application Server. With the WCF SQL adapter there's a lot of potential take-up as a simpler alternative to the ADO.NET Entity Framework, so if it requires a BizTalk license, there will be room for an open source alternative. &lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129794"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129794" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/129794.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/03/02/using-the-wcf-sql-adapter-in-.net-calling-stored-procedures.aspx</guid>
            <pubDate>Tue, 03 Mar 2009 00:42:45 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/129794.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/03/02/using-the-wcf-sql-adapter-in-.net-calling-stored-procedures.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/129794.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Receiving large WCF response messages in ESB Guidance</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/02/25/receiving-large-wcf-response-messages-in-esb-guidance.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;WCF bindings provide the &lt;em&gt;MaxReceivedMessageSize&lt;/em&gt; property, which lets you block any incoming messages on the client side over a given size (defaulting to 64Kb). If you're using message-based itinerary processing with ESB Guidance, when a WCF service returns a message larger than this default, you'll get a &lt;em&gt;System.ServiceModel.QuotaExceededException&lt;/em&gt; and the response message will be suspended: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;System.ServiceModel.CommunicationException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. ---&amp;gt; System.ServiceModel.QuotaExceededException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Setting the &lt;em&gt;MaxReceivedMessageSize&lt;/em&gt; property is straightforward in a configured WCF port, but in ESB Guidance the port is configured dynamically and there's no straightforward way to interrupt it and add your own WCF bindings. To give us access to the message and the port, we replaced the "DynamicSendResponse" port used in the GlobalBank.ESB sample with a simple orchestration. &lt;/p&gt;
&lt;p&gt;The orchestration has a direct-bound receive port filtering on the usual properties: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;(Microsoft.Practices.ESB.Itinerary.Schemas.ServiceName == "DynamicResolutionSolicitResp") &amp;amp;&amp;amp;  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;(Microsoft.Practices.ESB.Itinerary.Schemas.ServiceState == "Pending") &amp;amp;&amp;amp;  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;(Microsoft.Practices.ESB.Itinerary.Schemas.ServiceType == "Messaging") &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;- it then  builds the outgoing message for the service, and configures the dynamic send/receive port. At this point the message has all the properties you need configured by ESB (via the resolver pipeline component in the previous itinerary steps), so you can extract them to configure the port, and add any WCF binding configuration you need. &lt;/p&gt;
&lt;p&gt;We store the configuration in the Enterprise Single Sign-On application config store using &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/06/29/sso-config-tool.aspx"&gt;SSO Config Tool&lt;/a&gt;, so the expression to build the outgoing message and increase the received message size looks like this –  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;//setup port from context properties:  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;sptServiceProvider(Microsoft.XLANGs.BaseTypes.Address) = ServiceProviderRequest(BTS.OutboundTransportLocation);  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;sptServiceProvider(Microsoft.XLANGs.BaseTypes.TransportType) = ServiceProviderRequest(BTS.OutboundTransportType);  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;//set message size from config:  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;maxReceivedMessageSize = x.y.z.Configuration.X_Y_Z_Config.WCFMaxReceivedMessageSize;  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;ServiceProviderRequest(WCF.MaxReceivedMessageSize) = maxReceivedMessageSize; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;Microsoft.Practices.ESB.Adapter.AdapterMgr.SetMsgProperty(ServiceProviderRequest, typeof(WCF.MaxReceivedMessageSize), maxReceivedMessageSize); &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;//set timeout from config:  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;sendTimeout = x.y.z.Configuration.X_Y_Z_Config.WCFSendTimeout;  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;ServiceProviderRequest(WCF.SendTimeout) = sendTimeout;  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;Note that the WCF config is set on the message, not on the port. We're also setting timeout values here. When you're dealing with large messages, you may get operation timeouts as the default binding config from BizTalk is set to a pessimistic 1 minute. Value &lt;em&gt;WCF.SendTimeout&lt;/em&gt; specifies how long the BizTalk client waits for a response, and &lt;em&gt;WCF.ReceiveTimeout&lt;/em&gt; how long the BizTalk client allows for the reception of a request. If your WCF service is hosted in IIS and is long-running, you may also have an issue with IIS controlling execution times. See: &lt;a href="http://blogs.msdn.com/wenlong/archive/2008/03/10/why-changing-sendtimeout-does-not-help-for-hosted-wcf-services.aspx"&gt;Why changing SendTimeout does not help for hosted WCF services&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129677"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129677" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/129677.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/02/25/receiving-large-wcf-response-messages-in-esb-guidance.aspx</guid>
            <pubDate>Wed, 25 Feb 2009 23:51:53 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/129677.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/02/25/receiving-large-wcf-response-messages-in-esb-guidance.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/129677.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Generic WCF Error Handler for ESB Guidance</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/01/20/generic-wcf-error-handler-for-esb-guidance.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The management portal for ESB Guidance is an excellent tool which displays information on faults generated during the processing of messages through the ESB. It also exposes Web and WCF services for logging your own faults to the exception database, so you can record exceptions that occur in your own service providers and use the portal as a single view over the health of your SOA stack. &lt;/p&gt;
&lt;p&gt;The SubmitFault method of the ExceptionManagement service takes a FaultMessage object which must be correctly configured with Header and FaultException properties. It takes some trial-and-error to work out what needs populating – if any properties are missing or invalid, your fault won't be logged. I've put together a sample error handler on MSDN Code Gallery which populates a call correctly: &lt;a href="http://code.msdn.microsoft.com/ESBGErrorHandler"&gt;ESB Guidance Error Handler&lt;/a&gt;, which you can use as-is in your WCF services, or as a basis for your own handler. &lt;/p&gt;
&lt;p&gt;In the sample, the error handler is available to your service so you can manually log a fault for any exceptions that you catch, and you can also configure it as a service behaviour so it will log any uncaught exceptions in your WCF service. A sample service and client are provided for demonstration – set up the SampleService as a virtual directory and run SampleClient (you'll need the ESB Guidance Exception Management installed). &lt;/p&gt;
&lt;p&gt;To use the ServiceProviderErrorHandler add a config section in your web.config to specify how faults are logged: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;configSections&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;section&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;serviceProviderErrorHandlerConfiguration&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ESBGuidanceErrorHandler.Configuration.ServiceProviderErrorHandlerConfiguration, ESBGuidanceErrorHandler&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;configSections&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceProviderErrorHandlerConfiguration&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;exceptionHandlingUrl&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://localhost/ESB.ExceptionHandlingServices/ExceptionHandling.asmx&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;bizTalkApplication&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;BizTalk Application 1&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;faultCode&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;50054&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;errorType&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Service Provider exception&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;failureCategory&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;0&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;faultGeneratorName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ESBGuidanceErrorHandler&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceProviderErrorHandlerConfiguration&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This identifies the location of the ExceptionHandling service (the sample uses the SOAP entry point, but it's a simple change to use the WCF version as they have the same signature) and the descriptive text to categorise errors being logged, which will be shown in the portal. Note that the specified BizTalk Application must exist and the fault generator name is limited to 50 characters. Other values can contain any identifiers you like. &lt;/p&gt;
&lt;p&gt;With the config specified, it's a simple call to log a fault – passing the name of the service provider and the service, description and severity of the fault, and an exception: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;ServiceProviderErrorHandler&lt;/span&gt;.SubmitFault(&lt;span style="color: rgb(163, 21, 21);"&gt;"ErroringService"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"LogHandledException"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"Caught exception"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;FaultSeverity&lt;/span&gt;.Error, ex); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To register the ServiceProviderErrorHandler to catch any unhandled exceptions that occur just requires a behaviour extension in the WCF service configuration: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;services&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;service&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ErroringService&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;defaultServiceBehavior&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;endpoint&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;contract&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;IErroringService&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;binding&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;basicHttpBinding&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;service&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;services&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behavior&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;defaultServiceBehavior&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;                    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceMetadata&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;httpGetEnabled&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;true&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;                    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceDebug&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;true&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;                    &lt;em&gt;&amp;lt;&lt;/em&gt;&lt;/span&gt;&lt;em&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceProviderBehavior&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;                &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behavior&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviors&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;em&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;extensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;em&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviorExtensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;em&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;add&lt;/span&gt;&lt;span style="color: blue;"&gt; 				&lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;serviceProviderBehavior&lt;/span&gt;"&lt;span style="color: blue;"&gt; 				&lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ESBGuidanceErrorHandler.Behaviors.ServiceProviderBehavior, ESBGuidanceErrorHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=de4c0bb04730ca55&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;em&gt;&lt;span style="color: blue;"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;behaviorExtensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;em&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;extensions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Add this to all your WCF service providers and any exceptions will be logged and can be shown, filtered and subscribed to in the normal way.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128808"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128808" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/128808.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/01/20/generic-wcf-error-handler-for-esb-guidance.aspx</guid>
            <pubDate>Tue, 20 Jan 2009 14:43:29 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/128808.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/01/20/generic-wcf-error-handler-for-esb-guidance.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/128808.aspx</wfw:commentRss>
        </item>
        <item>
            <title>T4 template to generate Wix scripts to generate WCF MSIs in MSBuild</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/09/04/t4-template-to-generate-wix-scripts-to-generate-wcf-msis.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Snappy title. We have a project which contains lots of WCF Service projects, and we want to generate MSIs so we can deploy them to IIS. The gaps between the projects are minimal as they all use the same structure, so instead of having separate Setup or Wix files in each of the solutions, generating the WXS files on the fly was an option. &lt;/p&gt;
&lt;p&gt;The installer steps we wanted were reasonably simple: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;install WCF artifacts to the chosen directory (.svc and web.config files) &lt;/li&gt;
    &lt;li&gt;install WCF binaries to &lt;em&gt;the chosen directory\bin &lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;install dependencies to the GAC&lt;em&gt; 			&lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;create a virtual directory in IIS pointing to the install directory&lt;em&gt; 			&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The only UI we particularly needed was the choice of install directory, so the Wix for this fits into a fairly straightforward T4 template: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;template&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; language=&lt;/span&gt;"&lt;span style="color: blue;"&gt;C#&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;output&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; extension=&lt;/span&gt;"&lt;span style="color: blue;"&gt;.xml&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;assembly&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; name=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.dll&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;import&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; namespace=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.IO&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;import&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; namespace=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Security.Cryptography&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;import&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; namespace=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Text&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: gray;"&gt;&amp;lt;?xml&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;version="1.0"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;encoding="UTF-8"?&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: gray;"&gt;&amp;lt;Wix&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;xmlns="http://schemas.microsoft.com/wix/2006/wi"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Product&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetProductId() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;" &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;" &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Language="1033" &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Version="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; VersionNumber &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;" &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Manufacturer="Company" &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;UpgradeCode="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetUpgradeCode() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Package&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;InstallerVersion="200"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Compressed="yes"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Media&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="1"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Cabinet="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;.Install.cab"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;EmbedCab="yes"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="TARGETDIR"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="SourceDir"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="ProgramFilesFolder"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="CompanyFolder"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="Company"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="INSTALLLOCATION"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Component&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="Website"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Guid="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetNewGuid() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; foreach (string filePath in this.WcfArtifacts.Split(';')) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;            { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;                this.AddFile(filePath);     &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: navy; background-color: white;"&gt;            }&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;            &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Component&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; int index = 0; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;            foreach (string assemblyPath in this.WcfDependencies.Split(';')) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: navy; background-color: white;"&gt;            {&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;                &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Component&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="GACComponent_&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; index++ &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Guid="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetNewGuid() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;SharedDllRefCount="yes"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.AddAssemblyToGAC(assemblyPath); &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;                &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Component&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt;}&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WebsiteBin"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="bin"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;            &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Component&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WebsiteBin"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Guid="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetNewGuid() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;                &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.AddAssembly(this.WcfAssembly); &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;            &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Component&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Directory&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Directory&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Directory&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Directory&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;        &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Component&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="VirtualDir"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Guid="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetNewGuid() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;        &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;iis:WebVirtualDir&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WcfVirtualDir"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Alias="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName.TrimEnd(".Wcf".ToCharArray()) &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Directory="INSTALLLOCATION"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;WebSite="DefaultWebSite"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;            &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;iis:WebApplication&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WcfApplication"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;        &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/iis:WebVirtualDir&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Component&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Directory&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;      &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;iis:WebSite&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="DefaultWebSite"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Description="Default&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Web&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Site"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;        &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;iis:WebAddress&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="AllUnassigned"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Port="80"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/iis:WebSite&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Feature&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="ProductFeature"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Title="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Level="1"&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;ComponentRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="Website"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;ComponentRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WebsiteBin"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; int i = 0; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;            foreach (string assemblyPath in this.WcfDependencies.Split(';')) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: navy; background-color: white;"&gt;            {&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;ComponentRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="GACComponent_&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; i++ &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; } &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;ComponentRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="VirtualDir"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Feature&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;      &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Property&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WIXUI_INSTALLDIR"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Value="INSTALLLOCATION"/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;UIRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WixUI_InstallDir"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;WixVariable&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WixUIDialogBmp"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Value="$(WixPath)\SetupBackground.bmp"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;      &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Product&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: gray; font-family: Courier New; font-size: 10pt;"&gt;&amp;lt;/Wix&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#+&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string ServiceName &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;{ get{ return "$(ProjectName).$(ProjectFilter)"; }} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string VersionNumber &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;{ get{ return "$(Version)"; }} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string WcfArtifacts &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;{ get{ return @"@(WcfArtifacts)"; }} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string WcfAssembly &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;{ get{ return @"@(WcfAssembly)"; }} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string WcfDependencies &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: white;"&gt;{ get{ return @"@(WcfDependencies)"; }}&lt;/span&gt; 		&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt;"&gt;…&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;- the full template is here: &lt;a href="http://www.sixeyed.plus.com/fileDrop/code/T4Templates/Services.Wcf.wxs.tt"&gt;WCF Service Wix template&lt;/a&gt;.  &lt;/p&gt;
&lt;p&gt;A couple of interesting things here – the Guids are generated from the name of the elements (see &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/06/26/generating-deterministic-guids.aspx"&gt;Generating Deterministic Guids&lt;/a&gt;), so multiple versions will have the same Guid and will operate as updates, provided the name of the service doesn't change;  the tags for MSBuild properties in the template get resolved using the &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx"&gt;ExecuteT4Template MSBuild task&lt;/a&gt;; the GACd assemblies flag themselves as &lt;em&gt;SharedDllRefCount&lt;/em&gt; so if you uninstall this package, the files will be left in the GAC if any other packages use them, but removed if this is the only package that uses them. &lt;/p&gt;
&lt;p&gt;Another custom task is needed to resolve the dependencies of the WCF assembly (sample version here: &lt;a href="http://www.sixeyed.plus.com/fileDrop/code/MSBuild/Sixeyed.MSBuild.zip"&gt;MSBuild ResolveDependencies task&lt;/a&gt;), and the MSBuild snippet to run it together with the Wix commands looks like this: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Target&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ResolveWcfDependencies&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;!--&lt;/span&gt;&lt;span style="color: green;"&gt; List the dependencies for the Wcf service:&lt;/span&gt;&lt;span style="color: blue;"&gt;--&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ResolveDependencies&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;AssemblyList&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;@(WcfAssembly)&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Filter&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;$(CompanyName).$(ProductName)&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Output&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;TaskParameter&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;DependencyList&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;ItemName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;WcfDependencies&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ResolveDependencies&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Target&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Target&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;PublishWcf&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;DependsOnTargets&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt; ResolveWcfDependencies&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Condition&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;'@(WcfAssembly)' != ''&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;!--&lt;/span&gt;&lt;span style="color: green;"&gt; Create the wxs file: &lt;/span&gt;&lt;span style="color: blue;"&gt;--&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Message&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Text&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Determined Wcf dependencies: @(WcfDependencies)&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ExecuteT4Template&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;ToolPath&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;$(MSBuildProjectDirectory)\$(BuildBinDir)&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;TemplatePath&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;$(TemplateRoot)\Services.Wcf.wxs.tt&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;OutputPath&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;$(ArtefactWixDir)\$(ProductName).$(ProjectName).Wcf.wxs&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Output&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;TaskParameter&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TempFilePath&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;ItemName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;T4TempFilePath&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ExecuteT4Template&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Message&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Text&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;T4 template resolved to: @(T4TempFilePath)&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;!--&lt;/span&gt;&lt;span style="color: green;"&gt; Produce intermediate Wix obj:&lt;/span&gt;&lt;span style="color: blue;"&gt;--&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Exec&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Command&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;'&lt;span style="color: blue;"&gt;"$(WixPath)\candle" -out "$(ArtefactWixDir)\$(ProductName).$(ProjectName).Wcf.wixobj" "$(ArtefactWixDir)\$(ProductName).$(ProjectName).Wcf.wxs" -ext WixIIsExtension -ext WixUiExtension&lt;/span&gt;'&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;!--&lt;/span&gt;&lt;span style="color: green;"&gt; Produce MSI:&lt;/span&gt;&lt;span style="color: blue;"&gt;--&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Exec&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Command&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;'&lt;span style="color: blue;"&gt;"$(WixPath)\light" -out "$(PublishServiceDir)\$(ProductName).$(ProjectName).Wcf.msi" "$(ArtefactWixDir)\$(ProductName).$(ProjectName).Wcf.wixobj" -ext WixIIsExtension -ext WixUiExtension -cultures:en-us&lt;/span&gt;'&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Target&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;- we store all the intermediate files (the T4 template with resolved property values, WXS and WIXOBJ files) to help with debugging. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124932"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124932" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/124932.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/09/04/t4-template-to-generate-wix-scripts-to-generate-wcf-msis.aspx</guid>
            <pubDate>Thu, 04 Sep 2008 19:55:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/124932.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/09/04/t4-template-to-generate-wix-scripts-to-generate-wcf-msis.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/124932.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Flattening WSDL from WCF Services</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/07/30/flattening-wsdl-from-wcf-services.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you're hosting WCF services in IIS and try accessing the WSDL using &lt;strong&gt;ServiceDescriptionImporter.Import&lt;/strong&gt;,  you'll get an error saying &lt;em&gt;Unable to import binding BasicHttpBinding_IXyzService… &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;WCF separates out its schemas into logical components, which ServiceDescriptionImporter and other clients (including the &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/06/05/contract-first-codegen.aspx"&gt;ESBSimpleSamples ServiceClient generator&lt;/a&gt;) can't work with, as they're expecting a single flat WSDL. &lt;/p&gt;
&lt;p&gt;Christian Weyer from Thinktecture has a solution here: &lt;a href="http://blogs.thinktecture.com/cweyer/archive/2007/05/10/414840.aspx"&gt;Improving WCF Interoperability: Flattening your WSDL&lt;/a&gt;. If you download and build his sample project, copy &lt;strong&gt;Thinktecture.ServiceModel.Extensions.Description.dll&lt;/strong&gt; to your service bin folder and amend your .svc description to use the Thinktecture factory: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;% @ServiceHost Language=C# Service="Xyz.XyzService" Factory="Thinktecture.ServiceModel.Extensions.Description.FlatWsdlServiceHostFactory " %&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;- this will return a flattened WSDL, so tools expecting one file will work correctly.  &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124116"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124116" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/124116.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/07/30/flattening-wsdl-from-wcf-services.aspx</guid>
            <pubDate>Wed, 30 Jul 2008 17:23:15 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/124116.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/07/30/flattening-wsdl-from-wcf-services.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/124116.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>