<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://blogs.ugidotnet.org/dsantarelli/category/WCF.aspx</link>
        <description>WCF</description>
        <language>it-IT</language>
        <copyright>Dario Santarelli</copyright>
        <generator>Subtext Version 2.6.0.0</generator>
        <item>
            <title>[WCF 4.0] Default Endpoints</title>
            <link>http://blogs.ugidotnet.org/dsantarelli/archive/2011/02/19/wcf-4.0-default-endpoints.aspx</link>
            <description>&lt;p&gt;Un’ approccio introdotto in WCF 4.0 è la “&lt;a href="http://en.wikipedia.org/wiki/Convention_over_configuration"&gt;Convention Over Configuration&lt;/a&gt;”. Sostanzialmente essa permette di assegnare una configurazione predefinita ad un endpoint in assenza di una configurazione esplicita (cosa impossibile in WCF 3.x). Ciò avviene tramite la definizione di un mapping tra lo schema/protocollo (es. http, tcp etc.) e le varie tipologie di binding (es. BasicHttpBinding, NetTcpBinding etc.) all’interno del file:     &lt;br /&gt;
&lt;em&gt;%WINDIR%\Microsoft.NET\Framework\v4.0.30319\Config\machine.config.comments&lt;/em&gt; &lt;/p&gt;
&lt;font face="Consolas"&gt;
&lt;p class="MsoNormal" style="margin: 0cm 0cm 10pt; line-height: 13pt;"&gt;     &lt;span class="style1" lang="EN-US" style="line-height: 9pt; mso-ansi-language: en-us;"&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;font class="style2"&gt;&lt;span class="style1" lang="EN-US" style="line-height: 9pt; mso-ansi-language: en-us;"&gt;&lt;font color="#a31515"&gt;protocolMapping&lt;/font&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 9pt; mso-ansi-language: en-us;"&gt;&lt;font color="#0000ff"&gt;&lt;span class="style1"&gt;&amp;gt;          &lt;/span&gt;          &lt;br class="style1" /&gt;
&lt;span class="style1" style="mso-spacerun: yes;"&gt;    &lt;/span&gt;     &lt;span class="style1"&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="style1" lang="EN-US" style="line-height: 9pt; mso-ansi-language: en-us;"&gt;&lt;font color="#a31515"&gt;clear&lt;/font&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 9pt; mso-ansi-language: en-us;"&gt;&lt;font color="#0000ff"&gt;&lt;span class="style1"&gt; /&amp;gt;          &lt;/span&gt;          &lt;br class="style1" /&gt;
&lt;span class="style1" style="mso-spacerun: yes;"&gt;    &lt;/span&gt;     &lt;span class="style1"&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="style1" lang="EN-US" style="line-height: 9pt; mso-ansi-language: en-us;"&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;scheme&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span lang="EN-US" style="line-height: 9pt; mso-ansi-language: en-us;"&gt;&lt;font style="font-size: 8pt;"&gt;"&lt;/font&gt;&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt;http&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;binding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt;basicHttpBinding&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;bindingConfiguration&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;""&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;span class="style1"&gt; /&amp;gt;            &lt;/span&gt;            &lt;br class="style1" /&gt;
&lt;span class="style1" style="mso-spacerun: yes;"&gt;    &lt;/span&gt;     &lt;span class="style1"&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="style1"&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;scheme&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt;net.tcp&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;binding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt;netTcpBinding&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;bindingConfiguration&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;""&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;span class="style1"&gt; /&amp;gt;            &lt;/span&gt;            &lt;br class="style1" /&gt;
&lt;span class="style1" style="mso-spacerun: yes;"&gt;    &lt;/span&gt;     &lt;span class="style1"&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="style1"&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;scheme&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt;net.pipe&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;binding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt;netNamedPipeBinding&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;bindingConfiguration&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;""&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;span class="style1"&gt; /&amp;gt;            &lt;/span&gt;            &lt;br class="style1" /&gt;
&lt;span class="style1" style="mso-spacerun: yes;"&gt;    &lt;/span&gt;     &lt;span class="style1"&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="style1"&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;scheme&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt;net.msmq&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;binding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt;netMsmqBinding&lt;/font&gt;&lt;/span&gt;"&lt;span class="style1"&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;bindingConfiguration&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;""&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;span class="style1"&gt; /&amp;gt;            &lt;/span&gt;            &lt;br class="style1" /&gt;
&lt;span class="style1"&gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="style1"&gt;&lt;font color="#a31515"&gt;protocolMapping&lt;/font&gt;&lt;font color="#0000ff" style="font-size: 8pt;"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;Volendo verificare la cosa, creiamo un’ interfaccia di prova&lt;/p&gt;
&lt;span lang="EN-US" style="line-height: 12pt; mso-ansi-language: en-us; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;&lt;font face="Consolas"&gt;[&lt;span&gt;&lt;font color="#2b91af"&gt;ServiceContract&lt;/font&gt;&lt;/span&gt;]       &lt;br /&gt;
&lt;span&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;interface&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;IDummyService&lt;/font&gt;&lt;/span&gt;       &lt;br /&gt;
{       &lt;br /&gt;
   [&lt;span&gt;&lt;font color="#2b91af"&gt;OperationContract&lt;/font&gt;&lt;/span&gt;(IsOneWay=&lt;span&gt;&lt;font color="#0000ff"&gt;true&lt;/font&gt;&lt;/span&gt;)]       &lt;br /&gt;
   &lt;span&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt; DoNothing();          &lt;br /&gt;
}&lt;/font&gt;&lt;/span&gt;
&lt;p&gt;&lt;br /&gt;
Puntualizziamo il fatto che la scelta di impostare l’operation contract come “OneWay” deriva dal fatto che un contratto esposto da un endpoint che utilizza &lt;a href="http://msdn.microsoft.com/it-it/library/system.servicemodel.netmsmqbinding.aspx"&gt;NetMsmqBinding&lt;/a&gt; può supportare solo operazioni one-way. Implementiamo quindi l’interfaccia &lt;em&gt;IDummyService&lt;/em&gt;...&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;font face="Consolas"&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it;"&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it;"&gt;&lt;font face="Consolas"&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;MyDummyService&lt;/font&gt;&lt;/span&gt; : &lt;span&gt;&lt;font color="#2b91af"&gt;IDummyService&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;
{         &lt;br /&gt;
   &lt;span&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt; DoNothing() { }        &lt;br /&gt;
}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;     &lt;br /&gt;
Costruiamo un test per verificare quanto asserito, ponendo attenzione a non specificare alcuna configurazione per gli endpoint:&lt;/p&gt;
&lt;span lang="EN-US" style="line-height: 12pt; mso-ansi-language: en-us; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;&lt;font color="#2b91af" face="Consolas"&gt;ServiceHost&lt;/font&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 12pt; mso-ansi-language: en-us; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;&lt;font face="Consolas"&gt; host = &lt;span&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;ServiceHost&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#0000ff"&gt;typeof&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#2b91af"&gt;MyDummyService&lt;/font&gt;&lt;/span&gt;),       &lt;br /&gt;
                                 &lt;span style="mso-spacerun: yes;"&gt;  &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;Uri&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#a31515"&gt;"http://localhost:8080/MyDummyService"&lt;/font&gt;&lt;/span&gt;),       &lt;br /&gt;
                                   &lt;span&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;Uri&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#a31515"&gt;"net.tcp://localhost:8081/MyDummyService"&lt;/font&gt;&lt;/span&gt;),       &lt;br /&gt;
                                   &lt;span&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;Uri&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#a31515"&gt;"net.pipe://localhost/MyDummyService"&lt;/font&gt;&lt;/span&gt;),       &lt;br /&gt;
                                   &lt;span&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;Uri&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#a31515"&gt;"net.msmq://localhost/private/MyDummyService"&lt;/font&gt;&lt;/span&gt;));                        &lt;br /&gt;
host.Open();             &lt;br /&gt;
&lt;span style="mso-spacerun: yes;"&gt; &lt;/span&gt;       &lt;br /&gt;
&lt;span&gt;&lt;font color="#2b91af"&gt;Assert&lt;/font&gt;&lt;/span&gt;.AreEqual(4, host.Description.Endpoints.Count);             &lt;br /&gt;
&lt;span&gt;&lt;font color="#2b91af"&gt;Assert&lt;/font&gt;&lt;/span&gt;.IsTrue(host.Description.Endpoints[0].Binding &lt;span&gt;&lt;font color="#0000ff"&gt;is&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;BasicHttpBinding&lt;/font&gt;&lt;/span&gt;);       &lt;br /&gt;
&lt;span&gt;&lt;font color="#2b91af"&gt;Assert&lt;/font&gt;&lt;/span&gt;.IsTrue(host.Description.Endpoints[1].Binding &lt;span&gt;&lt;font color="#0000ff"&gt;is&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;NetTcpBinding&lt;/font&gt;&lt;/span&gt;);       &lt;br /&gt;
&lt;span&gt;&lt;font color="#2b91af"&gt;Assert&lt;/font&gt;&lt;/span&gt;.IsTrue(host.Description.Endpoints[2].Binding &lt;span&gt;&lt;font color="#0000ff"&gt;is&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;NetNamedPipeBinding&lt;/font&gt;&lt;/span&gt;);    &lt;br /&gt;
&lt;span&gt;&lt;font color="#2b91af"&gt;Assert&lt;/font&gt;&lt;/span&gt;.IsTrue(host.Description.Endpoints[3].Binding &lt;span&gt;&lt;font color="#0000ff"&gt;is&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;NetMsmqBinding&lt;/font&gt;&lt;/span&gt;);&lt;/font&gt;&lt;/span&gt;
&lt;p&gt;&lt;br /&gt;
Verde!    &lt;br /&gt;
Ovviamente, se ne abbiamo la necessità, possiamo effettuare l’override di questi mappings sia a livello di machine che a livello di application. Ad esempio, se specificassimo la seguente configurazione nell’app.config…&lt;/p&gt;
&lt;font face="Consolas"&gt;&lt;span style="line-height: 12pt; mso-ansi-language: it; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="line-height: 12pt; mso-ansi-language: it; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;&lt;font color="#a31515"&gt;configuration&lt;/font&gt;&lt;/span&gt;&lt;span style="line-height: 12pt; mso-ansi-language: it; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="line-height: 12pt; mso-ansi-language: it; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;    &lt;br /&gt;
&lt;font face="Consolas"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;  &amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#a31515"&gt;system.serviceModel&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;         &lt;br /&gt;
&lt;span&gt;    &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;protocolMapping&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;         &lt;br /&gt;
&lt;span&gt;      &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;scheme&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span&gt;&lt;font color="#0000ff"&gt;http&lt;/font&gt;&lt;/span&gt;"&lt;span&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;binding&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;"&lt;span&gt;&lt;font color="#0000ff"&gt;webHttpBinding&lt;/font&gt;&lt;/span&gt;"&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;/&amp;gt;&lt;/span&gt;         &lt;br /&gt;
&lt;span&gt;    &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;protocolMapping&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;         &lt;br /&gt;
&lt;span&gt;  &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;system.serviceModel&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;         &lt;br /&gt;
&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;configuration&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;
&lt;p&gt;&lt;br /&gt;
…il test precedente fallirebbe poiché lo schema http è stato assegnato al WebHttpBinding e non più al BasicHttpBinding. Invece, il seguente test avrebbe successo&lt;/p&gt;
&lt;span style="line-height: 12pt; mso-ansi-language: it; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;&lt;font color="#2b91af" face="Consolas"&gt;ServiceHost&lt;/font&gt;&lt;/span&gt;&lt;span style="line-height: 12pt; mso-ansi-language: it; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: it; mso-bidi-language: ar-sa;"&gt;&lt;font face="Consolas"&gt; host = &lt;span&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;ServiceHost&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#0000ff"&gt;typeof&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#2b91af"&gt;MyDummyService&lt;/font&gt;&lt;/span&gt;),&lt;span&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;Uri&lt;/font&gt;&lt;/span&gt;(&lt;span&gt;&lt;font color="#a31515"&gt;"http://localhost:8080/MyDummyService"&lt;/font&gt;&lt;/span&gt;));       &lt;br /&gt;
host.Open();       &lt;br /&gt;
&lt;span&gt;&lt;font color="#2b91af"&gt;Assert&lt;/font&gt;&lt;/span&gt;.IsTrue(host.Description.Endpoints[0].Binding &lt;span&gt;&lt;font color="#0000ff"&gt;is&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#2b91af"&gt;WebHttpBinding&lt;/font&gt;&lt;/span&gt;);&lt;/font&gt;&lt;/span&gt;
&lt;p&gt;&lt;br /&gt;
Per avere più informazioni riguardo al funzionamento di questa feature e delle altre novità di WCF 4.0 rimando a questo link MSDN:    &lt;br /&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ee354381.aspx"&gt;http://msdn.microsoft.com/en-us/library/ee354381.aspx&lt;/a&gt; (A Developer's Introduction to Windows Communication Foundation 4)&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:fac97a97-662d-4c1b-b933-529a57410aa7" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;Tag di Technorati: &lt;a rel="tag" href="http://technorati.com/tags/WCF"&gt;WCF&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/dsantarelli/aggbug/99741.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dario Santarelli</dc:creator>
            <guid>http://blogs.ugidotnet.org/dsantarelli/archive/2011/02/19/wcf-4.0-default-endpoints.aspx</guid>
            <pubDate>Sat, 19 Feb 2011 17:34:24 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/dsantarelli/archive/2011/02/19/wcf-4.0-default-endpoints.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/dsantarelli/comments/commentRss/99741.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/dsantarelli/services/trackbacks/99741.aspx</trackback:ping>
        </item>
        <item>
            <title>[WCF] IOperationBehavior e IParameterInspector</title>
            <link>http://blogs.ugidotnet.org/dsantarelli/archive/2009/02/24/wcf-ioperationbehavior-e-iparameterinspector.aspx</link>
            <description>&lt;p&gt;Dal punto di vista della flessibilità, ritengo che WCF sia una delle tecnologie più potenti attualmente disponibili per lo sviluppo di applicazioni orientate ai servizi. In particolare, una delle caratteristiche che apprezzo maggiormente è la facilità di personalizzazione del comportamento runtime degli OperationContract sia client-side che service-side ( &lt;a target="_blank" href="http://blogs.ugidotnet.org/dsantarelli/archive/2009/01/10/wcf-web-caching-con-wcf-rest-starter-kit.aspx"&gt;pratica&lt;/a&gt; per altro molto usata nel &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/netframework/cc950529.aspx"&gt;WCF REST Starter Kit&lt;/a&gt; :D ). &lt;br /&gt;
In questo post volevo soffermarmi proprio su questo aspetto, mostrando un semplice esempio di implementazione dell’interfaccia &lt;a target="_blank" href="http://msdn.microsoft.com/it-it/library/system.servicemodel.description.ioperationbehavior.aspx"&gt;IOperationBehavior&lt;/a&gt;, che per l'appunto definisce quattro metodi finalizzati all'estensione del runtime behavior di un'operation: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a target="_blank" href="http://msdn.microsoft.com/it-it/library/system.servicemodel.description.ioperationbehavior.addbindingparameters.aspx"&gt;AddBindingParameters &lt;/a&gt;: serve per aggiungere nuovi elementi di binding utilizzabili dall'operation in fase di esecuzione.  &lt;/li&gt;
    &lt;li&gt;&lt;a target="_blank" href="http://msdn.microsoft.com/it-it/library/system.servicemodel.description.ioperationbehavior.applyclientbehavior.aspx"&gt;ApplyClientBehavior &lt;/a&gt;: viene chiamato client-side 
    &lt;ul&gt;
        &lt;li&gt;prima che il contenuto della richiesta sia serializzato e inviato al service &lt;/li&gt;
        &lt;li&gt;dopo che la risposta è stata deserializzata ma prima che i valori restituiti vengano forniti al metodo proxy &lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a target="_blank" href="http://msdn.microsoft.com/it-it/library/system.servicemodel.description.ioperationbehavior.applydispatchbehavior.aspx"&gt;&lt;font color="#0033cc"&gt;ApplyDispatchBehavior&lt;/font&gt; &lt;/a&gt;: viene chiamato service-side dopo la deserializzazione dei parametri, ma prima che essi siano forniti all'operation del service. &lt;/li&gt;
    &lt;li&gt;&lt;a target="_blank" href="http://msdn.microsoft.com/it-it/library/system.servicemodel.description.ioperationbehavior.validate.aspx"&gt;&lt;font color="#0033cc"&gt;Validate&lt;/font&gt; &lt;/a&gt;: permette di verificare che l'operation soddisfi dei criteri custom ( es. autorizzazioni ). &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Vediamo ora una semplice implementazione che mette in evidenza come sia veramente semplice agganciare un OperationBehavior ad un OperationContract  tramite un attributo. Gli ambiti di applicazione sono veramente tanti: ad esempio potremmo usare questa tecnica service-side per eseguire della logica custom prima e dopo l’invocazione di un’operation da parte di un client. Nello specifico, supponiamo di voler scrivere in un file di log sul server sia i parametri di input passati all'operation che il risultato dell'invocazione. Per ottenere questo scenario necessitiamo anzitutto della definizione di un oggetto che sia in grado di ispezionare i parametri dell'operation sia prima che dopo la chiamata: in altre parole abbiamo bisogno di un &lt;a target="_blank" href="http://msdn.microsoft.com/it-it/library/system.servicemodel.dispatcher.iparameterinspector.aspx"&gt;IParameterInspector&lt;/a&gt;. Questa interfaccia definisce due metodi, &lt;em&gt;BeforeCall(…) &lt;/em&gt;e &lt;em&gt;AfterCall(…)&lt;/em&gt;&lt;em&gt;,&lt;/em&gt; che ci permettono di inserire della logica custom ( sempre sia client-side che service-side ) per accedere alle informazioni inerenti una operation ed i relativi parametri di input/output nelle fasi immediatamente precedenti e successive all’invocazione. &lt;br /&gt;
Partiamo dunque dal nostro IParameterInspector: &lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;public&lt;/span&gt; &lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ParameterLogInspector&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;IParameterInspector &lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FileInfo&lt;/span&gt; _logFileInfo; &lt;br /&gt;
&lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; ParameterLogInspector(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fileName) &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;_logFileInfo = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FileInfo&lt;/span&gt;(fileName); &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!_logFileInfo.Exists) _logFileInfo.Create();&lt;span style="mso-spacerun: yes"&gt;       &lt;br /&gt;
   &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;} &lt;br /&gt;
&lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;#region&lt;/span&gt; &lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;IParameterInspector Members &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; BeforeCall(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; operationName, &lt;span style="COLOR: blue"&gt;object&lt;/span&gt;[] inputs) &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: #2b91af"&gt;StringBuilder&lt;/span&gt; sb = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;StringBuilder&lt;/span&gt;(); &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; input &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; inputs) sb.AppendFormat(&lt;span style="COLOR: #a31515"&gt;"{0};"&lt;/span&gt;, input.ToString()); &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Log(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #a31515"&gt;"Operation \"{0}\" is calling... inputs: {1}"&lt;/span&gt;, operationName, sb.ToString())); &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;; &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;}&lt;span style="mso-spacerun: yes"&gt;        &lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;   public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; AfterCall(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; operationName, &lt;span style="COLOR: blue"&gt;object&lt;/span&gt;[] outputs, &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; returnValue, &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; correlationState) &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Log(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #a31515"&gt;"Operation \"{0}\" called. returnValue: {1}"&lt;/span&gt;,operationName,returnValue.ToString()));&lt;span style="mso-spacerun: yes"&gt;             &lt;br /&gt;
   &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;} &lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;   &lt;br /&gt;
   &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;#endregion &lt;br /&gt;
&lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Log(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; message) &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;StreamWriter&lt;/span&gt; sw = _logFileInfo.AppendText()) &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
       &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;sw.WriteLine(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #a31515"&gt;"{0}&amp;gt; {1}"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.Now.ToString(), message)); &lt;br /&gt;
     &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;} &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;} &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;/span&gt;
&lt;p&gt;&lt;br /&gt;
Quindi, ci posizioniamo all'interno del metodo &lt;em&gt;ApplyDispatchBehavior(...)&lt;/em&gt; semplicemente per aggiungere il nostro &lt;em&gt;IParameterInspector&lt;/em&gt; alla collection &lt;a target="_blank" href="http://msdn.microsoft.com/it-it/library/system.servicemodel.dispatcher.dispatchoperation.parameterinspectors.aspx"&gt;ParameterInspectors&lt;/a&gt; dell'oggetto &lt;a target="_blank" href="http://msdn.microsoft.com/it-it/library/system.servicemodel.dispatcher.dispatchoperation.aspx"&gt;DispatchOperation&lt;/a&gt; (che rappresenta l'operation service-side) : &lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;font face="Trebuchet MS" color="#000000"&gt;&lt;br /&gt;
&lt;/font&gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;public class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ParametersLog&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;Attribute&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;IOperationBehavior &lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; FileName { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;br /&gt;
&lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;#region&lt;/span&gt; &lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;IOperationBehavior Members &lt;br /&gt;
&lt;br /&gt;
  &lt;font color="#0000ff"&gt;... &lt;br /&gt;
&lt;/font&gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&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: #2b91af"&gt;OperationDescription&lt;/span&gt; operationDescription, &lt;span style="COLOR: #2b91af"&gt;DispatchOperation&lt;/span&gt; dispatchOperation) &lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;dispatchOperation.ParameterInspectors.Add(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ParameterLogInspector&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.FileName)); &lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;} &lt;br /&gt;
&lt;br /&gt;
  ... &lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;br /&gt;
  &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;#endregion &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;/span&gt; &lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
Il gioco è fatto: non rimane che decorare l'OperationContract di interesse con il nostro attributo &lt;em&gt;ParametersLog &lt;/em&gt;per ottenere l' estensione del runtime che ad ogni chiamata scriverà in un file di log i valori dei parametri di input/output .&lt;br /&gt;
&lt;br /&gt;
&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;[&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;] &lt;br /&gt;
&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IAuthentication &lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{ &lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;] &lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;[&lt;span style="COLOR: #2b91af"&gt;ParametersLog&lt;/span&gt;(FileName=&lt;span style="COLOR: #a31515"&gt;"C:/log.txt"&lt;/span&gt;)] &lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: #2b91af"&gt;UserInfo&lt;/span&gt; Login(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; userName, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; password); &lt;br /&gt;
&lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;] &lt;br /&gt;
  &lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Logout(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; userName); &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;/span&gt; &lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9003f381-bdb0-462c-b0cd-b70524b1dcbd" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tag: &lt;a rel="tag" href="http://technorati.com/tags/WCF"&gt;WCF&lt;/a&gt; &lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/dsantarelli/aggbug/95538.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dario Santarelli</dc:creator>
            <guid>http://blogs.ugidotnet.org/dsantarelli/archive/2009/02/24/wcf-ioperationbehavior-e-iparameterinspector.aspx</guid>
            <pubDate>Tue, 24 Feb 2009 16:02:08 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/dsantarelli/archive/2009/02/24/wcf-ioperationbehavior-e-iparameterinspector.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/dsantarelli/comments/commentRss/95538.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/dsantarelli/services/trackbacks/95538.aspx</trackback:ping>
        </item>
        <item>
            <title>[WCF] Operazioni asincrone client-side</title>
            <link>http://blogs.ugidotnet.org/dsantarelli/archive/2009/02/10/wcf-operazioni-asincrone-client-side.aspx</link>
            <description>&lt;p&gt;WCF è un framework concepito per sviluppare scenari di comunicazione completamente disaccoppiati sotto ogni punto di vista. In particolare, per quanto riguarda la sincronizzazione dei messaggi, è prevista internamente una rigida implementazione di pattern asincroni per ottenere chiamate non bloccanti tra i vari livelli strutturali. Esternamente, invece, WCF espone possibilità di programmazione asincrona sia client-side che server-side. L'aspetto interessante da approfondire in merito è come il programming model asincrono client-side non abbia nulla a che vedere con quello server-side: ovvero, un client può sostanzialmente invocare in modo asincrono un servizio indipendentemente dal fatto che esso sia implementato con un pattern sincrono piuttosto che asincrono.    &lt;br /&gt;Il disaccoppiamento avviene infatti a livello di trasporto quando i dati vengono serializzati/deserializzati.     &lt;br /&gt;Per capire l’importanza di tale feature pensiamo semplicemente ad un’ architettura N-tier che poggia su WCF: potremmo avere diverse “operation” che a loro volta utilizzano proxy client verso altre operation WCF, rendendo vitale l’utilizzo di pattern di comunicazione asincroni.  &lt;br /&gt;Vediamo un semplice esempio. Supponiamo di avere il seguente ServiceContract:     &lt;br /&gt;    &lt;br /&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;ServiceContract&lt;/span&gt;]      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;interface&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IAuthentication       &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{     &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]      &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: #2b91af"&gt;UserInfo&lt;/span&gt; Login(&lt;span style="color: blue"&gt;string&lt;/span&gt; username, &lt;span style="color: blue"&gt;string&lt;/span&gt; password);&lt;span style="mso-spacerun: yes"&gt;        &lt;br /&gt;        &lt;br /&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]      &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: blue"&gt;void&lt;/span&gt; Logout(&lt;span style="color: blue"&gt;string&lt;/span&gt; username);      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;}     &lt;br /&gt;&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Se lato client utilizzassimo &lt;a href="http://msdn.microsoft.com/en-us/library/aa347733.aspx" target="_blank"&gt;Svcutil&lt;/a&gt; ( con gli opportuni parametri ) o il solito “Add Service Reference” di VisualStudio, otterremmo la generazione automatica del seguente object model:    &lt;br /&gt;    &lt;br /&gt;&lt;img src="http://img4.imageshack.us/img4/4205/asyncpn6.jpg" /&gt;  &lt;br /&gt;    &lt;br /&gt;Come si può osservare abbiamo una versione asincrona client-side del ServiceContract &lt;em&gt;(IAuthentication)&lt;/em&gt;, un' interfaccia &lt;em&gt;&amp;lt;ServiceContract&amp;gt;Channel&lt;/em&gt; (&lt;em&gt;IAuthenticationChannel&lt;/em&gt;) ed una classe Client (&lt;em&gt;AuthenticationClient&lt;/em&gt;) che espone metodi di invocazione sia asincroni che sincroni. Nello specifico, si prospettano due possibili modalità di invocazione asincrona client-side di un’ operation: &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;1. Invocazione asincrona “event-based” (o “event-driven”)&lt;/em&gt;&lt;/strong&gt;  &lt;br /&gt;E' la modalità più semplice e raccomandata poiché richede solamente l’aggiunta di un EventHandler per ricevere una notifica all’occorrenza di una risposta. Questa modalità ( disponibile solo nel framework 3.5 e comunque solo per questo tipo di invocazione ) permette di sfruttare l’approccio asincrono event-based tramite un metodo nella forma &amp;lt;&lt;i&gt;operationName&lt;/i&gt;&amp;gt;&lt;em&gt;Async &lt;/em&gt;e l’intercettazione di un evento &amp;lt;&lt;i&gt;operationName&lt;/i&gt;&amp;gt;&lt;em&gt;Completed &lt;/em&gt;al cui interno si ha accesso al risultato dell’invocazione &amp;lt;&lt;i&gt;operationName&lt;/i&gt;&amp;gt;&lt;em&gt;CompletedEventArgs.&lt;/em&gt;    &lt;br /&gt;    &lt;br /&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;...     &lt;br /&gt;      &lt;br /&gt;ServiceReference.&lt;span style="color: #2b91af"&gt;AuthenticationClient&lt;/span&gt; client = &lt;span style="color: blue"&gt;new&lt;/span&gt; ServiceReference.&lt;span style="color: #2b91af"&gt;AuthenticationClient&lt;/span&gt;();      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;client.&lt;strong&gt;LoginCompleted&lt;/strong&gt; += &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;EventHandler&lt;/span&gt;&amp;lt;ServiceReference.&lt;span style="color: #2b91af"&gt;LoginCompletedEventArgs&lt;/span&gt;&amp;gt;(client_LoginCompleted);      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;client.&lt;strong&gt;LoginAsync&lt;/strong&gt;(&lt;span style="color: #a31515"&gt;"dario.santarelli"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"password"&lt;/span&gt;);      &lt;br /&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.ReadLine();      &lt;br /&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;client.Close();     &lt;br /&gt;      &lt;br /&gt;...&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; client_LoginCompleted(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, ServiceReference.&lt;span style="color: #2b91af"&gt;LoginCompletedEventArgs&lt;/span&gt; e)      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{     &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: #2b91af"&gt;UserInfo&lt;/span&gt; info = e.Result &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;UserInfo&lt;/span&gt;;      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;Console&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;.WriteLine(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"UserName: {0} - Password: {1}"&lt;/span&gt;,info.UserName,info.Email));      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;}&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us"&gt;     &lt;p /&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;   &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;2. Invocazione asincrona via ChannelFactory&lt;/em&gt;&lt;/strong&gt;    &lt;br /&gt;Il pattern asincrono previsto in questa modalità è quello classico previsto a partire dal framework 1.1: tramite lo split di un operation in due metodi ( &lt;em&gt;Begin&amp;lt;operationName&amp;gt;&lt;/em&gt; e &lt;em&gt;End&amp;lt;operationName&amp;gt; ), &lt;/em&gt;si sfruttano oggetti che implementano l’interfaccia &lt;a href="http://msdn.microsoft.com/en-us/library/system.iasyncresult.aspx" target="_blank"&gt;System.IAsyncResult&lt;/a&gt; per rappresentare lo stato di una operazione asincrona.&lt;/p&gt;  &lt;p&gt;...   &lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;EndpointAddress&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt; endpointAddress = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;EndpointAddress&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"http://.../AuthenticationService.svc"&lt;/span&gt;);      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;ServiceReference.&lt;span style="color: #2b91af"&gt;IAuthenticationChannel&lt;/span&gt; channelClient = &lt;span style="color: #2b91af"&gt;ChannelFactory&lt;/span&gt;&amp;lt;ServiceReference.&lt;span style="color: #2b91af"&gt;IAuthenticationChannel&lt;/span&gt;&amp;gt;.CreateChannel(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;BasicHttpBinding&lt;/span&gt;(), endpointAddress);      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: #2b91af"&gt;IAsyncResult&lt;/span&gt; result = channelClient.&lt;strong&gt;BeginLogin&lt;/strong&gt;(&lt;span style="color: #a31515"&gt;"dario.santarelli"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"password"&lt;/span&gt;, LoginCallBack, channelClient);      &lt;br /&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.ReadLine();      &lt;br /&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;channelClient.Close();     &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;channelClient.Dispose();     &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;       &lt;br /&gt;...   &lt;br /&gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: blue"&gt;protected&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; LoginCallBack(&lt;span style="color: #2b91af"&gt;IAsyncResult&lt;/span&gt; ar)      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;{     &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: #2b91af"&gt;UserInfo&lt;/span&gt; result = ((ServiceReference.&lt;span style="color: #2b91af"&gt;IAuthenticationChannel&lt;/span&gt;)ar.AsyncState).&lt;strong&gt;EndLogin&lt;/strong&gt;(ar);      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;Console&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Result: {0}"&lt;/span&gt;, result.UserName);      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;}&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us"&gt;     &lt;p /&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Conclusioni&lt;/em&gt;&lt;/strong&gt;    &lt;br /&gt;In entrambe le soluzioni presentate, una nostra application può invocare un’operazione in maniera asincrona anche se il servizio è implementato in maniera sincrona, allo stesso modo con cui una applicazione può usare lo stesso pattern per invocare in maniera asincrona un metodo sincrono locale. “Come” è poi implementato l’ OperationContract è assolutamente insignificante per il client.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Risorse MSDN:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms734701.aspx" target="_blank"&gt;Synchronous and Asynchronous Operations&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms730059.aspx" target="_blank"&gt;How to: Call WCF Service Operations Asynchronously&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb885132.aspx" target="_blank"&gt;How to: Call Operations Asynchronously Using a Channel Factory&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt; &lt;/p&gt;  &lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3e259f3a-8328-438b-9c46-85ad992f22e6" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Async" rel="tag"&gt;Async&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/dsantarelli/aggbug/95433.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dario Santarelli</dc:creator>
            <guid>http://blogs.ugidotnet.org/dsantarelli/archive/2009/02/10/wcf-operazioni-asincrone-client-side.aspx</guid>
            <pubDate>Tue, 10 Feb 2009 00:24:15 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/dsantarelli/archive/2009/02/10/wcf-operazioni-asincrone-client-side.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/dsantarelli/comments/commentRss/95433.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/dsantarelli/services/trackbacks/95433.aspx</trackback:ping>
        </item>
        <item>
            <title>[WCF] Esempio di Integration Test</title>
            <link>http://blogs.ugidotnet.org/dsantarelli/archive/2009/01/31/wcf-esempio-di-integration-test.aspx</link>
            <description>&lt;p&gt;Esistono molti strumenti e tecniche per effettuare un &lt;a href="http://en.wikipedia.org/wiki/Integration_testing" target="_blank"&gt;integration test&lt;/a&gt; di servizi WCF. Un modo che ho trovato molto semplice ed utile si ottiene sruttando il framework di unit testing di Visual Studio: infatti, utilizzando due metodi decorati rispettivamente con &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.classinitializeattribute(VS.80).aspx" target="_blank"&gt;ClassInitialize&lt;/a&gt; e &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.classcleanupattribute(VS.80).aspx" target="_blank"&gt;ClassCleanup&lt;/a&gt; possiamo gestire il ciclo di vita di un ServiceHost, evitando così il deploy preventivo (es. Cassini, IIS etc.) del servizio.     &lt;br /&gt;Nel seguente esempio viene mostrata questa tecnica supponendo di voler testare un servizio di autenticazione &lt;em&gt;AuthenticationService&lt;/em&gt; che implementa un service contract &lt;em&gt;IAuthentication,&lt;/em&gt; il quale definisce due metodi: Login(…) e Logout().     &lt;br /&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;     &lt;br /&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;[&lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;]       &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;AuthenticationUnitTest        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;{      &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ServiceHost&lt;/span&gt; _serviceHost;       &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; _address = &lt;span style="color: #a31515"&gt;"AuthenticationService"&lt;/span&gt;;       &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; _baseAddress = &lt;span style="color: #a31515"&gt;"http://127.0.0.1:5656/"&lt;/span&gt;;       &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;     &lt;br /&gt;  [&lt;span style="color: #2b91af"&gt;ClassInitialize&lt;/span&gt;]       &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; ServiceHostInitialize(&lt;span style="color: #2b91af"&gt;TestContext&lt;/span&gt; testContext)       &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;{      &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;_serviceHost = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ServiceHost&lt;/span&gt;(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;AuthenticationService&lt;/span&gt;), &lt;span style="color: blue"&gt;new&lt;/span&gt;[] { &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;(_baseAddress) });       &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;_serviceHost.AddServiceEndpoint(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;IAuthentication&lt;/span&gt;), &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;WSHttpBinding&lt;/span&gt;(), _address);       &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;_serviceHost.Open();      &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;}      &lt;br /&gt;      &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;[&lt;span style="color: #2b91af"&gt;ClassCleanup&lt;/span&gt;]       &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; ServiceHostCleanup() { _serviceHost.Close(); }       &lt;br /&gt;      &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;[&lt;span style="color: #2b91af"&gt;TestMethod&lt;/span&gt;]       &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; AuthenticateUser()       &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;{      &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; userName = &lt;span style="color: #a31515"&gt;"dario.santarelli"&lt;/span&gt;;       &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; password = &lt;span style="color: #a31515"&gt;"password"&lt;/span&gt;;       &lt;br /&gt;      &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: #2b91af"&gt;EndpointAddress&lt;/span&gt; endpointAddress = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;EndpointAddress&lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"{0}{1}"&lt;/span&gt;, _baseAddress,_address));       &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: #2b91af"&gt;IAuthentication&lt;/span&gt; proxy = &lt;span style="color: #2b91af"&gt;ChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;IAuthentication&lt;/span&gt;&amp;gt;.CreateChannel(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;WSHttpBinding&lt;/span&gt;(), endpointAddress);       &lt;br /&gt;      &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: #2b91af"&gt;UserInfo&lt;/span&gt; userInfo = proxy.Login(userName, password);       &lt;br /&gt;      &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.IsNotNull(userInfo);       &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-ansi-language: en-us"&gt;&lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.AreEqual(userInfo.Username, userName);       &lt;br /&gt;      &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;proxy.Logout(userName);&lt;span style="mso-spacerun: yes"&gt;            &lt;br /&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;}      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes"&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;Update&lt;/strong&gt;: con questa tecnica non si intende sostituire il test in ambiente di produzione, bensì fornire un modo “base” per verificare il funzionamento di una WCF Service Library. Infatti, come si può notare, in questo caso sia lo UnitTest che il ServiceHost girano nello stesso AppDomain, il che NON garantisce by design il corretto comportamento del test come se fosse in produzione. Per avere test maggiormente efficaci, si consiglia l’utilizzo di soluzioni più “evolute” come &lt;a href="http://msdn.microsoft.com/en-us/library/bb552363.aspx" target="_blank"&gt;WcfSvcHost&lt;/a&gt; o, meglio, direttamente un ambiente di test dedicato su IIS :D.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;    &lt;/p&gt;&lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8c99e46d-5b0e-4b82-a844-c7763f7d5abe" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Testing" rel="tag"&gt;Testing&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/dsantarelli/aggbug/95355.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dario Santarelli</dc:creator>
            <guid>http://blogs.ugidotnet.org/dsantarelli/archive/2009/01/31/wcf-esempio-di-integration-test.aspx</guid>
            <pubDate>Sat, 31 Jan 2009 17:22:29 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/dsantarelli/archive/2009/01/31/wcf-esempio-di-integration-test.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/dsantarelli/comments/commentRss/95355.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/dsantarelli/services/trackbacks/95355.aspx</trackback:ping>
        </item>
        <item>
            <title>[WCF] Web Caching con WCF REST Starter Kit</title>
            <link>http://blogs.ugidotnet.org/dsantarelli/archive/2009/01/10/wcf-web-caching-con-wcf-rest-starter-kit.aspx</link>
            <description>&lt;p&gt;Il &lt;a href="http://www.codeplex.com/aspnet/Wiki/View.aspx?title=WCF%20REST" target="_blank"&gt;WCF REST Starter Kit&lt;/a&gt; rende disponibile tra le varie utility anche una semplice soluzione per abilitare il web caching per WCF sfruttando l'interazione con la proprietà &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.cache.aspx" target="_blank"&gt;HttpResponse.Cache&lt;/a&gt; di ASP.NET. La soluzione si basa sull'utilizzo di un attributo &lt;span style="color: #2b91af"&gt;&lt;strong&gt;WebCache&lt;/strong&gt; &lt;/span&gt;con cui decorare i nostri OperationContract che sono suscettibili a meccanismi di caching secondo una specifica profilatura. L'attributo è definito all'interno della library &lt;em&gt;Microsoft.ServiceModel.Web.dll&lt;/em&gt; fornita con il Kit. Vediamo nel dettaglio i vari aspetti di utilizzo aiutandoci con un semplice esempio: la pubblicazione di un feed RSS 2.0 che gestisca un meccanismo di caching web in base al numero di item richiesti (es. 10, 20 etc.. ).    &lt;br /&gt;Supponiamo di avere un ServiceContract come il seguente:     &lt;br /&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;     &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;ServiceContract&lt;/span&gt;(SessionMode=&lt;span style="color: #2b91af"&gt;SessionMode&lt;/span&gt;.NotAllowed, &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;ProtectionLevel=&lt;span style="color: #2b91af"&gt;ProtectionLevel&lt;/span&gt;.None)]      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;interface&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IServiceRSS       &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;{     &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&lt;strong&gt;[&lt;span style="color: #2b91af"&gt;WebCache&lt;/span&gt;(CacheProfileName = &lt;span style="color: #a31515"&gt;"RssCacheDefault"&lt;/span&gt;)]        &lt;br /&gt;&lt;/strong&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;WebGet&lt;/span&gt;(UriTemplate = &lt;span style="color: #a31515"&gt;"?numItems={num}"&lt;/span&gt;)]      &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; color: #2b91af; font-family: " courier="" new="; mso-no-proof: yes"&gt;Rss20FeedFormatter&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="" new="; mso-no-proof: yes"&gt; GetRss20(&lt;span style="color: blue"&gt;int&lt;/span&gt; num);&lt;span style="mso-spacerun: yes"&gt;                &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;}&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;  &lt;br /&gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;Notiamo subito la presenza dell'attributo &lt;em&gt;WebCache&lt;/em&gt; la cui proprietà &lt;em&gt;CacheProfileName&lt;/em&gt; serve per specificare il nome della nostra profilatura di caching (es. "&lt;em&gt;RssCacheDefault"&lt;/em&gt;). Il comportamento di caching è configurabile sia valorizzando da codice le proprietà dell'attributo &lt;em&gt;WebCache&lt;/em&gt; (vedi figura sotto) che dichiarativamente nella sezione &lt;a href="http://msdn.microsoft.com/en-us/library/ms228244.aspx" target="_blank"&gt;outputCacheProfiles&lt;/a&gt; di ASP.NET.  &lt;br /&gt;Qua sotto viene riportato un esempio di configurazione per il nostro l'esempio.     &lt;br /&gt;    &lt;br /&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;system.web&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;caching&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;outputCacheSettings&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;      &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;outputCacheProfiles&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;        &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;clear&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;/&amp;gt;     &lt;br /&gt;        &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;add&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: red; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;name&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;"&lt;span style="color: blue"&gt;RssCacheDefault&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;duration&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;60&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;enabled&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;location&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;ServerAndClient&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;varyByParam&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;numItems&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;       &lt;br /&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-no-proof: yes"&gt;outputCacheProfiles&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-no-proof: yes"&gt;outputCacheSettings&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;caching&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;...     &lt;br /&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;system.web&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt;        &lt;br /&gt;...&lt;/span&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;system.serviceModel&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;&lt;strong&gt;   &lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;serviceHostingEnvironment&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: red; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;aspNetCompatibilityEnabled&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;/strong&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&lt;strong&gt;"&lt;span style="color: blue"&gt;true&lt;/span&gt;"&lt;/strong&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;/&amp;gt;&lt;/strong&gt;        &lt;br /&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;services&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;     &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;service &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;TestCachingApp.SampleServiceRSS&lt;/span&gt;"&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: red; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;behaviorConfiguration&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;"&lt;span style="color: blue"&gt;SampleServiceRSSBehavior&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;       &lt;br /&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;endpoint&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: red; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;address&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&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;webHttpBinding&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;TestCachingApp.IServiceRSS&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;endpoint&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;span style="mso-spacerun: yes"&gt;        &lt;br /&gt;        ...          &lt;br /&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;service&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;   &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;services&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; color: blue; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&amp;gt;     &lt;br /&gt;  ...&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;  &lt;br /&gt;&lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;system.serviceModel&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;     &lt;br /&gt;&lt;/span&gt;E' importante notare come occorra abilitare la compatibilità dell'ambiente di hosting del servizio WCF con ASP.NET, impostando a "true" l'attributo &lt;span lang="EN-US" style="font-size: 8pt; color: red; font-family: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;aspNetCompatibilityEnabled &lt;/span&gt;del tag &lt;span lang="EN-US" style="font-size: 8pt; color: #a31515; font-family: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;serviceHostingEnvironment&lt;/span&gt;.    &lt;br /&gt;    &lt;br /&gt;A questo punto il gioco è fatto!  &lt;br /&gt;Nell'implementazione del nostro servizio dobbiamo porre attenzione ad impostare la compatibilità con ASP.NET mediante l'attributo &lt;span style="color: #2b91af"&gt;AspNetCompatibilityRequirements&lt;/span&gt; :  &lt;br /&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;     &lt;br /&gt;[&lt;span style="color: #2b91af"&gt;AspNetCompatibilityRequirements&lt;/span&gt;(RequirementsMode = &lt;span style="color: #2b91af"&gt;AspNetCompatibilityRequirementsMode&lt;/span&gt;.Allowed)]      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;ServiceBehavior&lt;/span&gt;(IncludeExceptionDetailInFaults = &lt;span style="color: blue"&gt;true&lt;/span&gt;, InstanceContextMode = &lt;span style="color: #2b91af"&gt;InstanceContextMode&lt;/span&gt;.Single,      &lt;br /&gt;                 &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;ConcurrencyMode = &lt;span style="color: #2b91af"&gt;ConcurrencyMode&lt;/span&gt;.Single)]      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SampleServiceRSS&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;IServiceRSS       &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;{&lt;span style="mso-spacerun: yes"&gt;        &lt;br /&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Rss20FeedFormatter&lt;/span&gt; GetRss20(&lt;span style="color: blue"&gt;int&lt;/span&gt; num)      &lt;br /&gt;  &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;{     &lt;br /&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&lt;span style="color: #2b91af"&gt;SyndicationFeed&lt;/span&gt; feed = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SyndicationFeed&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"Title: ..."&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Description: ..."&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;("&lt;span style="color: #a31515"&gt;http://tempuri.org"&lt;/span&gt;));      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;    ...     &lt;br /&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: 'Courier New'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="color: green"&gt;    // Initialize the feed with 'num' items&lt;/span&gt;&lt;/span&gt;      &lt;br /&gt;    ...      &lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;    &lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt; font-family: " courier="" new="; mso-ansi-language: EN-US; mso-no-proof: yes"&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Rss20FeedFormatter&lt;/span&gt;(feed);&lt;span style="mso-spacerun: yes"&gt;             &lt;br /&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="" new="; mso-no-proof: yes"&gt;}&lt;span style="mso-spacerun: yes"&gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: " courier="" new="; mso-no-proof: yes"&gt;} &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Poiché l'uso di un meccanismo di caching costituisce una prassi ormai ordinaria nei vari paradigmi di programmazione Web, questo tipo di soluzione che integra la Web Cache di ASP.NET all'interno di WCF costituisce sicuramente un vantaggio significativo soprattutto per motivi pratici. Sebbene esistano scenari che richiedono soluzioni di natura diversa (es. &lt;a href="http://msdn.microsoft.com/en-us/library/cc309103.aspx" target="_blank"&gt;Enterprise Library Caching Block&lt;/a&gt; :D ), questo approccio può risolvere elegantemente i casi più comuni.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Behind the Scenes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Per chi fosse interessato ad approfondire l'argomento riporto alcune note secondo me interessanti.   &lt;br /&gt;L'attributo WebCache è implementato come un operation behavior di WCF ed implementa l'interfaccia &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.ioperationbehavior.aspx" target="_blank"&gt;IOperationBehavior&lt;/a&gt;. Il trucco si trova nell'implementazione del metodo &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.ioperationbehavior.applydispatchbehavior.aspx" target="_blank"&gt;ApplyDispatchBehavior&lt;/a&gt; di tale interfaccia: ogni volta che a run-time viene invocato un metodo decorato con l'attibuto WebCache, il nostro eventuale profilo di caching (ovvero un oggetto di tipo &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.outputcacheprofile.aspx" target="_blank"&gt;Systen.Web.Configuration.OutputCacheProfile&lt;/a&gt;) viene passato ad un' istanza di una classe utility del kit: &lt;i&gt;CachingParameterInspector&lt;/i&gt; (che implementa &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iparameterinspector.aspx" target="_blank"&gt;IParameterInspector&lt;/a&gt;). Questa classe in pratica non fa altro che provvedere alla configurazione della proprietà &lt;em&gt;HttpContext.Current.Response.Cache.&lt;/em&gt;     &lt;br /&gt;L'aspetto interessante si trova proprio a questo punto: la classe &lt;i&gt;CachingParameterInspector&lt;/i&gt; creata viene aggiunta alla &lt;a href="http://msdn.microsoft.com/it-it/library/system.servicemodel.dispatcher.dispatchoperation.parameterinspectors.aspx" target="_blank"&gt;collection&lt;/a&gt; di ParameterIspector dell' oggetto &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.dispatchoperation.aspx" target="_blank"&gt;DispatchOperation&lt;/a&gt; passato in input come argomento del metodo. In questo modo il runtime scatenerà l'esecuzione degli algoritmi di caching all'interno dell'infrastruttura di ASP.NET secondo la nostra eventuale profilatura.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;img src="http://img82.imageshack.us/img82/6599/webcacheattributeor8.jpg" /&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:fda916cc-8ad1-4ff2-a7f3-1ffef5f59f78" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ASP.NET" rel="tag"&gt;ASP.NET&lt;/a&gt;,&lt;a href="http://technorati.com/tags/RSS" rel="tag"&gt;RSS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Caching" rel="tag"&gt;Caching&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/dsantarelli/aggbug/95153.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dario Santarelli</dc:creator>
            <guid>http://blogs.ugidotnet.org/dsantarelli/archive/2009/01/10/wcf-web-caching-con-wcf-rest-starter-kit.aspx</guid>
            <pubDate>Sat, 10 Jan 2009 17:16:28 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/dsantarelli/archive/2009/01/10/wcf-web-caching-con-wcf-rest-starter-kit.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/dsantarelli/comments/commentRss/95153.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/dsantarelli/services/trackbacks/95153.aspx</trackback:ping>
        </item>
        <item>
            <title>WCF REST Starter Kit</title>
            <link>http://blogs.ugidotnet.org/dsantarelli/archive/2008/11/05/wcf-rest-starter-kit.aspx</link>
            <description>&lt;p&gt;Da pochi giorni ho iniziato a studiare il &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/netframework/cc950529.aspx"&gt;WCF REST Starter Kit&lt;/a&gt;, un insieme veramente completo di di feature, template Visual Studio ed esempi pratici per realizzare servizi WCF in stile &lt;a target="_blank" href="http://en.wikipedia.org/wiki/Representational_State_Transfer"&gt;REST&lt;/a&gt; . &lt;br /&gt;
Niente di nuovo per chi sguazza già da (molto) tempo nel mondo REST... tuttavia devo dire che è stata apportata una graditissima semplificazione dell'utilizzo delle potenzialità di WCF su HTTP (es. caching, conditional PUT...) nonché una maggiore produttività relativamente a servizi sempre più comuni come Atom feed/Publishing Protocol.&lt;/p&gt;
&lt;p&gt;Per chi fosse interessato all'argomento, consiglio la lettura di questo bellissimo articolo: &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/dd203052.aspx"&gt;A Guide to Designing and Building RESTful Web Services with WCF 3.5&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Buona lettura :)&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="" src="http://i.msdn.microsoft.com/dd203052.image008(en-us).jpg" /&gt;&lt;br /&gt;
&lt;/p&gt;&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e00388eb-dbb4-43f9-9640-806b5f397e09" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px" /&gt;

&lt;p&gt;
&lt;/p&gt;&lt;div class="wlWriterSmartContent" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tag: &lt;a rel="tag" href="http://technorati.com/tags/WCF"&gt;WCF&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/REST"&gt;REST&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;img src="http://blogs.ugidotnet.org/dsantarelli/aggbug/94528.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dario Santarelli</dc:creator>
            <guid>http://blogs.ugidotnet.org/dsantarelli/archive/2008/11/05/wcf-rest-starter-kit.aspx</guid>
            <pubDate>Wed, 05 Nov 2008 19:25:24 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/dsantarelli/archive/2008/11/05/wcf-rest-starter-kit.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/dsantarelli/comments/commentRss/94528.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/dsantarelli/services/trackbacks/94528.aspx</trackback:ping>
        </item>
        <item>
            <title>[WCF] Inviare e ricevere messaggi POX</title>
            <link>http://blogs.ugidotnet.org/dsantarelli/archive/2008/07/20/wcf-inviare-e-ricevere-messaggi-pox.aspx</link>
            <description>&lt;p&gt;Nel framework 3.5 abbiamo il supporto diretto all'implementazione di servizi POX all'interno di WCF. In questo post intendo dunque mostrare come generare e trasmettere messaggi "plain old XML" (ovvero costituiti esclusivamente da un payload XML) utilizzando il programming model messo a disposizione da WCF.    &lt;br /&gt;&lt;em&gt;Domanda&lt;/em&gt;: quando si ha bisogno di inviare/ricevere messaggi POX?     &lt;br /&gt;&lt;em&gt;Risposta&lt;/em&gt;: quando i client non supportano nativamente protocolli basati su SOAP oppure quando è richiesto un "leggero" scambio di dati via HTTP senza alcun requisito relativo a standard come WS-* (es. invio di un semplice feed RSS). In aggiunta, un'infrastruttura POX/HTTP costituisce la base naturale per l'implementazione di applicazioni Web REST-ful (es. il client invia una richiesta HTTP del tipo "GET http://.../customers/39" e il service risponde con un semplice documento POX contenente le informazioni di un customer).    &lt;br /&gt;Vediamo dunque come realizzare un semplice scenario client-server WCF per lo scambio di messaggi POX su HTTP:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Service  &lt;br /&gt;&lt;/strong&gt;Partiamo da un contratto &lt;em&gt;ICustomerService&lt;/em&gt; di esempio, che prevede un solo metodo &lt;em&gt;ProcessMessage&lt;/em&gt;: &lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;[&lt;span style="color: #2b91af"&gt;ServiceContract&lt;/span&gt;]       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;interface&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ICustomerService        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;{      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;[&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;(Action = &lt;span style="color: #a31515"&gt;"*"&lt;/span&gt;, ReplyAction = &lt;span style="color: #a31515"&gt;"*"&lt;/span&gt;, &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;IsOneWay=&lt;span style="color: blue"&gt;false&lt;/span&gt;, &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;ProtectionLevel=System.Net.Security.&lt;span style="color: #2b91af"&gt;ProtectionLevel&lt;/span&gt;.None)]       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="mso-spacerun: yes"&gt;   &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Message&lt;/span&gt; ProcessMessage(&lt;span style="color: #2b91af"&gt;Message&lt;/span&gt; request);       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Consideriamo immediatamente due aspetti:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Nel contesto di default di WCF, gli attributi &lt;em&gt;Action&lt;/em&gt; e &lt;em&gt;ReplyAction&lt;/em&gt; servono per impostare rispettivamente l'azione WS-Addressing del messaggio di richiesta e l'azione SOAP relativa al messaggio di risposta. Infatti, per default WCF utilizza le azioni specificate nell'header SOAP per elaborare correttamente i messaggi scambiati tra client e service. Nel nostro caso, la "wildcard action" (*) bypassa questo comportamento e permette quindi il dispatch di un qualunque messaggio ricevuto dell'endpoint del servizio verso il nostro metodo &lt;em&gt;ProcessMessage&lt;/em&gt;. &lt;/li&gt;    &lt;li&gt;Sia l'argomento che il valore restituito dal metodo ProcessMessage sono degli oggetti di tipo &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.aspx" target="_blank"&gt;System.ServiceModel.Channels.Message&lt;/a&gt;, una nuova astrazione che ci permette di creare e manipolare messaggi "raw", nonostante essa rappresenti nativamente una busta SOAP a tutti gli effetti. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Tutto diventa più chiaro se osserviamo l'implementazione del servizio: la classe &lt;em&gt;CustomerService&lt;/em&gt; elabora una richiesta POX in ingresso e restituisce un Message contenente dati XML relativi ad un Customer.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;public&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;CustomerService&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ICustomerService&lt;/span&gt;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;{      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt; ProcessMessage(&lt;span style="color: #2b91af"&gt;Message&lt;/span&gt; request)       &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;{&lt;span style="mso-spacerun: yes"&gt;            &lt;br /&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;XmlDictionaryReader&lt;/span&gt; reader = request.GetReaderAtBodyContents();       &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; customerID = reader.ReadElementContentAsString();&lt;span style="mso-spacerun: yes"&gt;                                   &lt;br /&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;Customer&lt;/span&gt; customer = GetCustomerById(customerID);       &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;Message&lt;/span&gt; response = &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt;.CreateMessage(&lt;span style="color: #2b91af"&gt;MessageVersion&lt;/span&gt;.None, &lt;span style="color: #a31515"&gt;"*"&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;CustomerInfoBodyWriter&lt;/span&gt;(&lt;span style="color: blue"&gt;true&lt;/span&gt;, customer));       &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; response;       &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;}&lt;span style="mso-spacerun: yes"&gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;}      &lt;br /&gt;&lt;/span&gt;    &lt;br /&gt;Per creare un messaggio POX specifico per le nostre esigenze utilizzando la classe Message, abbiamo semplicemente bisogno di invocarne il metodo statico &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.createmessage.aspx" target="_blank"&gt;CreateMessage&lt;/a&gt;, il quale possiede diversi overload a supporto del trasferimento in modalità sia push che pull. In questo caso è stato usato l'overload "push-mode" che si avvale di un &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.bodywriter.aspx" target="_blank"&gt;BodyWriter&lt;/a&gt; custom ottenuto ereditando la classe base astratta, in modo da avere il pieno controllo sulla creazione del messaggio POX da inviare al client tramite l'override del metodo &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.onwritebodycontents.aspx" target="_blank"&gt;OnWriteBodyContents&lt;/a&gt;.     &lt;br /&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;     &lt;br /&gt;public&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;CustomerInfoBodyWriter&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;BodyWriter        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;{      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Customer&lt;/span&gt; _customer;       &lt;br /&gt;  &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; CustomerInfoBodyWriter(&lt;span style="color: blue"&gt;bool&lt;/span&gt; isBuffered, &lt;span style="color: #2b91af"&gt;Customer&lt;/span&gt; customer) &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;: &lt;span style="color: blue"&gt;base&lt;/span&gt;(isBuffered)       &lt;br /&gt;  {       &lt;br /&gt;     _customer = customer;       &lt;br /&gt;  }       &lt;br /&gt;      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;protected&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; OnWriteBodyContents(&lt;span style="color: #2b91af"&gt;XmlDictionaryWriter&lt;/span&gt; writer)       &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;{      &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;writer.WriteStartElement(&lt;span style="color: #a31515"&gt;"CustomerInfo"&lt;/span&gt;);       &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;writer.WriteAttributeString(&lt;span style="color: #a31515"&gt;"id"&lt;/span&gt;, _customer.ID);       &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;writer.WriteAttributeString(&lt;span style="color: #a31515"&gt;"name"&lt;/span&gt;, _customer.Name);       &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;writer.WriteAttributeString(&lt;span style="color: #a31515"&gt;"email"&lt;/span&gt;, _customer.Email);       &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;writer.WriteEndElement();      &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;writer.Flush();      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;}&lt;span style="mso-spacerun: yes"&gt;     &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Vediamo infine la configurazione dell'endpoint, che si interfaccia con la rete tramite un &lt;a href="http://msdn.microsoft.com/en-us/library/aa347793.aspx" target="_blank"&gt;customBinding&lt;/a&gt; che prevede la generazione di stream su HTTP facendo uso di un encoder che permette la ricezione e l'invio di messaggi POX privi di un qualunque incapsulamento SOAP (&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;textMessageEncoding&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;messageVersion&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;None&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;).     &lt;br /&gt;    &lt;br /&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;configuration&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;system.serviceModel&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;bindings&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;      &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;customBinding&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;         &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;binding&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;name&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;poxBinding&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;        &lt;br /&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;textMessageEncoding&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;messageVersion&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;None&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;  &lt;br /&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;httpTransport&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;transferMode&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;StreamedResponse&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;maxBufferSize&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1024&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;        &lt;br /&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;binding&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;      &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;customBinding&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;     &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;bindings&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;     &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;services&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;         &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;service&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;name&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;SamplePOXService.CustomerService&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;        &lt;br /&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;host&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;             &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;baseAddresses&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;                 &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;add&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;baseAddress&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;="&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;http://localhost:4971/"&lt;/span&gt;&lt;span style="color: blue"&gt; /&amp;gt;        &lt;br /&gt;             &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;baseAddresses&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;            &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;host&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;            &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;endpoint&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;address&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;customers&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;binding&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;customBinding&lt;/span&gt;"&lt;span style="color: blue"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;poxBinding&lt;/span&gt;"       &lt;br /&gt;                              &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;contract&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;=&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;"&lt;span style="color: blue"&gt;ServiceClassLibrary.ICustomerService&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;        &lt;br /&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;service&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;      &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;services&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;    &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;system.serviceModel&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: #a31515; line-height: 115%; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;configuration&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; line-height: 115%; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;Client&lt;/strong&gt;     &lt;br /&gt;Il client POX condivide ovviamente la stessa configurazione del servizio, in maniera tale che la richiesta generata sia anch'essa POX su HTTP. Ecco quindi un semplice esempio di client WCF che genera un Message POX di richiesta contenente un ID di un Customer e stampa quindi a video l'XML risultante dall'invocazione del servizio.     &lt;br /&gt;    &lt;br /&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;ChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ICustomerService&lt;/span&gt;&amp;gt; channelFactory = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ICustomerService&lt;/span&gt;&amp;gt;(&lt;span style="color: #a31515"&gt;"CustomerService_ClientEndPoint"&lt;/span&gt;);       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;ICustomerService&lt;/span&gt; customer_service = channelFactory.CreateChannel();       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; customerID = &lt;span style="color: #a31515"&gt;"1"&lt;/span&gt;;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;Message&lt;/span&gt; request = &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt;.CreateMessage(&lt;span style="color: #2b91af"&gt;MessageVersion&lt;/span&gt;.None, &lt;span style="color: #a31515"&gt;"*"&lt;/span&gt;, customerID);       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;Message&lt;/span&gt; response = customer_service.ProcessMessage(request);       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;XmlDictionaryReader&lt;/span&gt; reader = response.GetReaderAtBodyContents();&lt;span style="mso-spacerun: yes"&gt;            &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"{0}"&lt;/span&gt;, reader.ReadOuterXml());&lt;span style="mso-spacerun: yes"&gt;            &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; line-height: 115%; font-family: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.ReadLine();&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Analizzando il traffico generato per l'esempio proposto, si rileva che i messaggi scambiati sono effettivamente di dimensioni minime. Degna di nota è inoltre l'introduzione dell' &lt;em&gt;xmlns&lt;/em&gt; nella generazione di default di un Message POX ottenuto tramite l'overload di &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.createmessage.aspx" target="_blank"&gt;CreateMessage&lt;/a&gt; che prevede il BodyWriter di default:    &lt;br /&gt;    &lt;br /&gt;&lt;em&gt;Request:&lt;/em&gt; &amp;lt;string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"&amp;gt;1&amp;lt;/string&amp;gt;     &lt;br /&gt;&lt;em&gt;Response:&lt;/em&gt; &amp;lt;CustomerInfo id="1" name="Dario Santarelli" email="dario.santarelli@xxx.yy" /&amp;gt;&lt;/p&gt;  &lt;p&gt;Come già anticipato all'inizio di questo post, l'utilizzo di un' infrastruttura POX/HTTP è consigliabile per: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;soluzioni in cui i client non possiedono nativamente il supporto allo standard SOAP o comunque a protocolli non-HTTP &lt;/li&gt;    &lt;li&gt;scenari in cui lo scambio dati deve essere il più leggero possibile ed in cui occorre aumentare sensibilmente le prestazioni del ciclo "request-response" (vedi AJAX). &lt;/li&gt;    &lt;li&gt;implementazioni REST-ful &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Chiaramente un esempio come quello mostrato non contempla affatto l'aspetto "security": HTTPS a parte, se si intende utilizzare POX/HTTP senza alcun meccanismo di autenticazione ed encryption dei dati, è comunque obbligatorio NON trasmettere messaggi contenenti dati sensibili.&lt;/p&gt;  &lt;p&gt;Per maggiori informazioni, consiglio la lettura di questo articolo MSDN: &lt;a href="http://msdn.microsoft.com/en-us/library/aa395208.aspx" target="_blank"&gt;REST and POX&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Technorati tags: &lt;img alt=" " src="http://static.technorati.com/static/img/pub/icon-utag-16x13.png?tag=POX" /&gt;&lt;a href="http://technorati.com/tags/POX/"&gt;POX&lt;/a&gt;, &lt;img alt=" " src="http://static.technorati.com/static/img/pub/icon-utag-16x13.png?tag=REST" /&gt;&lt;a href="http://technorati.com/tags/REST/"&gt;REST&lt;/a&gt;, &lt;img alt=" " src="http://static.technorati.com/static/img/pub/icon-utag-16x13.png?tag=WCF" /&gt;&lt;a href="http://technorati.com/tags/WCF/"&gt;WCF&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/dsantarelli/aggbug/93466.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dario Santarelli</dc:creator>
            <guid>http://blogs.ugidotnet.org/dsantarelli/archive/2008/07/20/wcf-inviare-e-ricevere-messaggi-pox.aspx</guid>
            <pubDate>Sun, 20 Jul 2008 15:25:24 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/dsantarelli/archive/2008/07/20/wcf-inviare-e-ricevere-messaggi-pox.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/dsantarelli/comments/commentRss/93466.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/dsantarelli/services/trackbacks/93466.aspx</trackback:ping>
        </item>
        <item>
            <title>Cardspace e WCF: autenticazione claim-based</title>
            <link>http://blogs.ugidotnet.org/dsantarelli/archive/2008/03/17/cardspace-e-wcf-autenticazione-claim-based.aspx</link>
            <description>&lt;p&gt;Partiamo da un concetto preliminare: WCF permette ad una applicazione sia client che server di richedere credenziali sia a livello di trasporto che di messaggio. In particolare, ecco le opzioni disponibili:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;Transport-Level&lt;/strong&gt;: None, Basic, Digest, NTLM,  Windows, Certificate. &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Message-Level&lt;/strong&gt;: None, Username, Windows, IssuedToken, Certificate.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;E' inutile precisare che il protocollo utilizzato per fornire credenziali deve essere poi abbinato opportunamente al tipo di binding previsto per lo scambio dei messaggi. Una volta stabilito il protocollo di autenticazione, bisogna stabilire il meccanismo di scambio di credenziali, che può avvenire sia programmaticamente (tramite la classe &lt;a target="_blank" href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.description.clientcredentials.aspx"&gt;ClientCredentials&lt;/a&gt; del namespace &lt;em&gt;System.ServiceModel.Description, &lt;/em&gt;esposta sia dal proxy del servizio che dal channel factory) che dichiarativamente da configurazione (sezione &lt;a target="_blank" href="http://msdn2.microsoft.com/en-us/library/ms731370.aspx"&gt;&amp;lt;serviceCredentials&amp;gt;&lt;/a&gt; ad esempio per specificare un certificato locale).&lt;/p&gt;
&lt;p&gt;Passiamo ora a Windows Cardspace, un 'identity selector' introdotto a partire dal framework 3.0 per gestire più identità digitali per ciascun utente secondo uno schema claim-based. Come molti sapranno una 'Carspace information card' può essere &lt;em&gt;personal&lt;/em&gt; o &lt;em&gt;managed&lt;/em&gt; e definisce un insieme di &lt;a target="_blank" href="http://msdn2.microsoft.com/en-us/library/ms733083.aspx"&gt;claims&lt;/a&gt; rappresentati di default da token &lt;a target="_blank" href="http://en.wikipedia.org/wiki/SAML"&gt;SAML&lt;/a&gt; 1.1. &lt;br /&gt;
WCF integra CardSpace tramite &lt;a target="_blank" href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.wsfederationhttpbinding.aspx"&gt;WSFederationHttpBinding&lt;/a&gt;, un binding che permette di esporre servizi via HTTP facendo affidamento su token forniti da un identity provider. Le credenziali sono di tipo &lt;strong&gt;IssuedToken&lt;/strong&gt; a livello di messaggio ed i parametri richiesti dal binding sono pressoché simili a quelli che si utilizzano all'interno &lt;a target="_blank" href="http://www.microsoft.com/uk/msdn/screencasts/screencast/26/Using-Windows-CardSpace-with-a-Web-Page.aspx"&gt;dell' embedding nelle pagine web&lt;/a&gt; adibito all' attivazione del CardSpace identity selector.&lt;br /&gt;
Ecco un esempio di configurazione di un servizio WCF che richiede token SAML che includono obbligatoriamente i claim PPID (Private Personal Identifier) e email. Osserviamo inoltre come il servizio debba obbligatoriamente fornire un certificato per abilitare lo scambio sicuro di dati sensibili.&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-pagination: none; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;system.serviceModel&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;span style="mso-spacerun: yes"&gt;  &lt;br /&gt;
 &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;...&lt;br /&gt;
 &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;bindings&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
   &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;wsFederationHttpBinding&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
     &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;binding&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;name&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;ws_FederationHttpBinding&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br /&gt;
       &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;security&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;mode&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;Message&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br /&gt;
         &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;message&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;issuedTokenType&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1&lt;/span&gt;" &lt;br /&gt;
                  &lt;span style="COLOR: red"&gt;negotiateServiceCredential&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; &amp;gt;&lt;br /&gt;
           &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;claimTypeRequirements&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: blue"&gt;&lt;br /&gt;
             &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;add&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;claimType&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;isOptional&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;/&amp;gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;             &amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;add&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;claimType&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;isOptional&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;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
           &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;claimTypeRequirements&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
           &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;issuer&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;address&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;http://schemas.xmlsoap.org/ws/2005/05/identity/issuer/self&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br /&gt;
         &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;message&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
        &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;security&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
      &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;binding&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
    &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;wsFederationHttpBinding&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
   &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;bindings&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
   &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;behaviors&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
     &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
       &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;behavior&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;name&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;SecureServiceBehavior&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br /&gt;
         &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;serviceCredentials&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
           &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;issuedTokenAuthentication&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;strong&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;allowUntrustedRsaIssuers&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;/strong&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;strong&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;/strong&gt;&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br /&gt;
           &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;serviceCertificate&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;findValue&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;RPKey&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;storeLocation&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;LocalMachine&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;storeName&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;My&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;x509FindType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;FindBySubjectName&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br /&gt;
         &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;serviceCredentials&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
        &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;behavior&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
      &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
 &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;behaviors&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;system.serviceModel&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;/span&gt;&lt;span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-ansi-language: en-us"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
La proprietà &lt;a target="_blank" href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.security.issuedtokenservicecredential.allowuntrustedrsaissuers.aspx?PHPSESSID=gmkmem7inohg2q677fst152mr6"&gt;allowUntrustedRsaIssuers&lt;/a&gt; impostata a "true" nella sezione &lt;a target="_blank" href="http://msdn2.microsoft.com/en-us/library/ms731342.aspx"&gt;&amp;lt;issuedTokenAuthentication&amp;gt;&lt;/a&gt; serve ad ammettere anche card di tipo &lt;em&gt;personal&lt;/em&gt;, che generano token non-trusted, al contrario delle card &lt;em&gt;managed&lt;/em&gt;. Lato client, la configurazione da utilizzare è pressoché identica, con la differenza che il client accede alla chiave pubblica utilizzata dal servizio per cifrare i messaggi. In questo aspetto, SvcUtil può velocizzare il nostro lavoro generando una vesione base-64 della chiave pubblica che possiamo quindi inserire nel file di configurazione evitando l'istallazione del certificato sullo store.&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-pagination: none; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;system.serviceModel&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
  &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;bindings&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
    &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;wsFederationHttpBinding&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;...&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;wsFederationHttpBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br /&gt;
  &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;bindings&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
  &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;client&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
    &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;...&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: blue"&gt;    &lt;br /&gt;
    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;identity&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
      &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;certificate&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;encodedValue&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;chiave pubblica codificata base64&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br /&gt;
    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;identity&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
   &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;endpoint&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
  &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;client&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'"&gt;system.serviceModel&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;Lato client, Windows CardSpace è 'triggerato' da WCF nel momento in cui l'issuer nella configurazione del servizio attiva la selezione di una card &lt;em&gt;personal&lt;/em&gt; che soddisfi i claims specificati nel binding. Le card &lt;em&gt;managed&lt;/em&gt; (rilasciate da un identity provider esterno) sono obbligatorie invece quando il tipo di token o i claim richiesti non possono essere soddisfatti dalle card personali. &lt;br /&gt;
A livello di messaggio, il token rilasciato da CardSpace verrà incapsulato nell'header del messaggio SOAP, il quale verrà decifrato e validato dal server prima di passare all'estrazione ed all'elaborazione dei claim. Nel caso di card di tipo &lt;em&gt;personal&lt;/em&gt; (dove i claim sono auto-forniti dall'utente), è importante basare l'identificazione univoca dell'account tramite il claim PPID. &lt;br /&gt;
Il codice seguente mostra proprio come accedere ai claim di una &lt;em&gt;personal&lt;/em&gt; card partendo dalla classe &lt;a target="_blank" href="http://msdn2.microsoft.com/en-us/library/system.identitymodel.policy.authorizationcontext.aspx"&gt;AuthorizationContext&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt; System.ServiceModel;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt; System.IdentityModel.Policy;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt; System.IdentityModel.Claims;&lt;br /&gt;
...&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: #2b91af"&gt;AuthorizationContext&lt;/span&gt; authorization_Context = &lt;span style="COLOR: #2b91af"&gt;ServiceSecurityContext&lt;/span&gt;.Current.AuthorizationContext;&lt;span style="mso-spacerun: yes"&gt;           &lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ClaimSet&lt;/span&gt; claim_set &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; authorization_Context.ClaimSets)&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;{ &lt;br /&gt;
   &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt;&amp;gt; claims = claim_set.FindClaims(&lt;span style="COLOR: #2b91af"&gt;ClaimTypes&lt;/span&gt;.PPID, &lt;span style="COLOR: #2b91af"&gt;Rights&lt;/span&gt;.PossessProperty);&lt;span style="mso-spacerun: yes"&gt;                &lt;br /&gt;
   &lt;span style="FONT-SIZE: 8pt; COLOR: green; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-ansi-language: it; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: it; mso-bidi-language: ar-sa"&gt;//Controllo sui claim forniti...&lt;/span&gt; &lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-pagination: none; mso-layout-grid-align: none"&gt;&lt;br /&gt;
per quanto concerne invece l'utilizzo di card &lt;em&gt;managed&lt;/em&gt;, abbiamo una possibiltà in più dal momento che i claim hanno un proprietario identificabile da un identity provider affidabile, a cui corrisponde un &lt;a target="_blank" href="http://msdn2.microsoft.com/en-us/library/system.identitymodel.claims.claimset.aspx"&gt;ClaimSet&lt;/a&gt; che spesso include un claim identificativo con la chiave pubblica dell'identity provider (&lt;span style="COLOR: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Rsa):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt; System.ServiceModel;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt; System.IdentityModel.Policy;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt; System.IdentityModel.Claims;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt; &lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;System.Security.Cryptography&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-pagination: none; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: #2b91af"&gt;...&lt;br /&gt;
&lt;br /&gt;
ClaimSet&lt;/span&gt; csIssuer = cs.Issuer;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt;&amp;gt; issuerClaims = csIssuer.FindClaims(&lt;span style="COLOR: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Rsa, &lt;span style="COLOR: #2b91af"&gt;Rights&lt;/span&gt;.Identity);&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt; c &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; issuerClaims)&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;br /&gt;
  &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: #2b91af"&gt;RSACryptoServiceProvider&lt;/span&gt; rsa = c.Resource &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; RSACryptoServiceProvider;&lt;br /&gt;
  &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (rsa != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;
  &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;span style="mso-spacerun: yes"&gt;                    &lt;br /&gt;
    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: green"&gt;// claim exists; check the public key to identify the IP&lt;br /&gt;
  &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
Evidentemente l'utilizzo di card &lt;em&gt;managed&lt;/em&gt; è maggiormente consigliata dal momento che rende più semplice la selezione di una identity da parte di un utente nonché la generazione di un insieme di claim associati ai diritti dell'utente verso il sistema partendo da token trusted rilasciati da identity provider affidabili. &lt;br /&gt;
&lt;br /&gt;
Technorati tags: &lt;a href="http://technorati.com/tag/WCF"&gt;&lt;img alt=" " src="http://static.technorati.com/static/img/pub/icon-utag-16x13.png?tag=WCF" /&gt;WCF&lt;/a&gt;, &lt;a href="http://technorati.com/tag/Cardspace"&gt;&lt;img alt=" " src="http://static.technorati.com/static/img/pub/icon-utag-16x13.png?tag=Cardspace" /&gt;Cardspace&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/dsantarelli/aggbug/91745.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Dario Santarelli</dc:creator>
            <guid>http://blogs.ugidotnet.org/dsantarelli/archive/2008/03/17/cardspace-e-wcf-autenticazione-claim-based.aspx</guid>
            <pubDate>Mon, 17 Mar 2008 17:25:11 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/dsantarelli/archive/2008/03/17/cardspace-e-wcf-autenticazione-claim-based.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/dsantarelli/comments/commentRss/91745.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/dsantarelli/services/trackbacks/91745.aspx</trackback:ping>
        </item>
    </channel>
</rss>