<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" version="2.0">
  <channel>
    <title>Matevž Gačnik's Weblog - .NET 3.0 - WCF</title>
    <link>https://www.request-response.com/blog/</link>
    <description>Technology Philanthropy</description>
    <image>
      <url>http://www.request-response.com/blog/images/favicon.jpg</url>
      <title>Matevž Gačnik's Weblog - .NET 3.0 - WCF</title>
      <link>https://www.request-response.com/blog/</link>
    </image>
    <language>en-us</language>
    <copyright>Matevz Gacnik</copyright>
    <lastBuildDate>Sat, 05 Jul 2008 12:18:06 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>matevz.gacnik@gmail.com</managingEditor>
    <webMaster>matevz.gacnik@gmail.com</webMaster>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of our core products, <a href="http://gama-system.com/Content.aspx?id=20050200">Gama
System eArchive</a> was <a href="http://www.merriam-webster.com/dictionary/accredit">accredited</a> last
week.
</p>
        <p>
This is <strong>the first accreditation</strong> of a domestic product and <strong>the
first one</strong> covering long term electronic document storage in a SOA based system.
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <em>Every document stored inside the Gama System eArchive product is now legally legal.
No questions asked.</em>
          </p>
        </blockquote>
        <p>
Accreditation is done by a <a href="http://www.arhiv.gov.si/en/">national body</a> and
represents the last step in a formal acknowledgement to holiness.
</p>
        <p align="center">
          <img src="http://www.request-response.com/blog/content/binary/archive1.jpg" />
        </p>
        <p>
That means a lot to me, even more to <a href="http://www.gama-system.si">our company</a>.
</p>
        <p>
The following blog entries were (in)directly inspired by the development of this product:
</p>
        <ul>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,f37eda08-845c-4b0a-a66c-ea9cec03c06b.aspx">Laws
and Digital Signatures</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx">Reliable
Messaging and Retry Timeouts</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx">Approaches
to Document Style Parameter Models</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,26149053-63bc-495e-bab0-8d14e7e46190.aspx">XmlSerializer,
Ambient XML Namespaces and Digital Signatures</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx">Security
Sessions and Service Throttling</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx">Reliable
Message Delivery</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx">Reliable
Message Delivery Continued</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,03fb0e40-b446-42b5-ad90-3be9b0260cb5.aspx">Durable
Reliable Messaging</a>
          </li>
        </ul>
        <p>
We've made <strong>a lot of effort</strong> to get this thing developed and accredited.
The certificate is <a href="http://www.request-response.com/blog/content/binary/e_ars_2007_003.pdf">here</a>.
</p>
        <p>
          <a href="http://www.arhiv.gov.si/si/e_hramba_dokumentarnega_gradiva/akreditacija/register_akreditirane_opreme_in_storitev">This</a>, <a href="http://www.posta.si/Namizje.aspx?tabid=746">this</a>, <a href="http://www.agencijanet.si/gama-system-e-arhiv-inovacija-leta-med-malimi-in-srednjimi-podjetji/">this</a>, <a href="http://finance.si/214263">this</a>, <a href="http://www.mojmikro.si/mreza/po_slovensko/ucinkovito_upravljanje_dokumentov_in_varna_e-hramba_podatkov">this</a>, <a href="http://mladipodjetnik.si/arhiv/novice/clani-tehnoloskega-parka-ljubljana-izbrani-med-10-najbolj-inovativnih-podjetij-v-sloveniji">this</a>, <a href="http://www.mojmikro.si/news/gama_system_pricakuje_preboj_med_svetovno_elito">this</a>, <a href="http://www.imix.ba/">this</a>, <a href="http://www.ashrafcom.com/edoc.htm">this</a> and <a href="http://www.si21.com/news.php?id=62696">t</a><a href="http://download.microsoft.com/download/7/D/E/7DE50907-87DD-4FFB-B10F-44A891EB49EC/cs_posta-slovenije-arhiviranje.doc">h</a><a href="http://www.agencijanet.si/slovenska-podjetja-na-cebit-u-2008/">o</a><a href="http://download.microsoft.com/download/F/2/4/F248F674-5D6E-430D-9C31-76546D57C2A3/CS%20Posta%20CEP.DOC">s</a><a href="http://www.agencijanet.si/matevzu-gacniku-ze-tretjic-mandat-microsoftovega-regionalnega-direktorja/">e</a> are
direct approvals of our correct decisions.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0" />
      </body>
      <title>Accreditus: Gama System eArchive</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0.aspx</link>
      <pubDate>Sat, 05 Jul 2008 12:18:06 GMT</pubDate>
      <description>&lt;p&gt;
One of our core products, &lt;a href="http://gama-system.com/Content.aspx?id=20050200"&gt;Gama
System eArchive&lt;/a&gt; was &lt;a href="http://www.merriam-webster.com/dictionary/accredit"&gt;accredited&lt;/a&gt; last
week.
&lt;/p&gt;
&lt;p&gt;
This is &lt;strong&gt;the first accreditation&lt;/strong&gt; of a domestic product and &lt;strong&gt;the
first one&lt;/strong&gt; covering long term electronic document storage in a SOA based system.
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;em&gt;Every document stored inside the Gama System eArchive product is now legally legal.
No questions asked.&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Accreditation is done by a &lt;a href="http://www.arhiv.gov.si/en/"&gt;national body&lt;/a&gt;&amp;nbsp;and
represents the last step in a formal acknowledgement to holiness.
&lt;/p&gt;
&lt;p align=center&gt;
&lt;img src="http://www.request-response.com/blog/content/binary/archive1.jpg"&gt;
&lt;/p&gt;
&lt;p&gt;
That means a lot to me, even more to &lt;a href="http://www.gama-system.si"&gt;our company&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
The following blog entries were (in)directly inspired by the development of this product:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,f37eda08-845c-4b0a-a66c-ea9cec03c06b.aspx"&gt;Laws
and Digital Signatures&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx"&gt;Reliable
Messaging and Retry Timeouts&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx"&gt;Approaches
to Document Style Parameter Models&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,26149053-63bc-495e-bab0-8d14e7e46190.aspx"&gt;XmlSerializer,
Ambient XML Namespaces and Digital Signatures&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx"&gt;Security
Sessions and Service Throttling&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx"&gt;Reliable
Message Delivery&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx"&gt;Reliable
Message Delivery Continued&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,03fb0e40-b446-42b5-ad90-3be9b0260cb5.aspx"&gt;Durable
Reliable Messaging&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
We've made &lt;strong&gt;a lot of effort&lt;/strong&gt; to get this thing developed and accredited.
The certificate is &lt;a href="http://www.request-response.com/blog/content/binary/e_ars_2007_003.pdf"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.arhiv.gov.si/si/e_hramba_dokumentarnega_gradiva/akreditacija/register_akreditirane_opreme_in_storitev"&gt;This&lt;/a&gt;, &lt;a href="http://www.posta.si/Namizje.aspx?tabid=746"&gt;this&lt;/a&gt;, &lt;a href="http://www.agencijanet.si/gama-system-e-arhiv-inovacija-leta-med-malimi-in-srednjimi-podjetji/"&gt;this&lt;/a&gt;, &lt;a href="http://finance.si/214263"&gt;this&lt;/a&gt;, &lt;a href="http://www.mojmikro.si/mreza/po_slovensko/ucinkovito_upravljanje_dokumentov_in_varna_e-hramba_podatkov"&gt;this&lt;/a&gt;, &lt;a href="http://mladipodjetnik.si/arhiv/novice/clani-tehnoloskega-parka-ljubljana-izbrani-med-10-najbolj-inovativnih-podjetij-v-sloveniji"&gt;this&lt;/a&gt;, &lt;a href="http://www.mojmikro.si/news/gama_system_pricakuje_preboj_med_svetovno_elito"&gt;this&lt;/a&gt;, &lt;a href="http://www.imix.ba/"&gt;this&lt;/a&gt;, &lt;a href="http://www.ashrafcom.com/edoc.htm"&gt;this&lt;/a&gt;&amp;nbsp;and &lt;a href="http://www.si21.com/news.php?id=62696"&gt;t&lt;/a&gt;&lt;a href="http://download.microsoft.com/download/7/D/E/7DE50907-87DD-4FFB-B10F-44A891EB49EC/cs_posta-slovenije-arhiviranje.doc"&gt;h&lt;/a&gt;&lt;a href="http://www.agencijanet.si/slovenska-podjetja-na-cebit-u-2008/"&gt;o&lt;/a&gt;&lt;a href="http://download.microsoft.com/download/F/2/4/F248F674-5D6E-430D-9C31-76546D57C2A3/CS%20Posta%20CEP.DOC"&gt;s&lt;/a&gt;&lt;a href="http://www.agencijanet.si/matevzu-gacniku-ze-tretjic-mandat-microsoftovega-regionalnega-direktorja/"&gt;e&lt;/a&gt; are
direct approvals of our correct decisions.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,dc2c17a8-a37b-4aa5-9e73-b0c55efe22f0.aspx</comments>
      <category>.NET 3.0 - General</category>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.5 - WCF</category>
      <category>Other</category>
      <category>Personal</category>
      <category>Work</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=a510f1dc-23bb-42aa-b683-a70c4740bfe5</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a510f1dc-23bb-42aa-b683-a70c4740bfe5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There is a <em>serious limitation</em> present in the RTM version of WCF 3.0/3.5 regarding
control of WS-RM retry messages during a <strong>reliable session</strong> saga.
</p>
        <p>
Let me try to explain the concept.
</p>
        <p>
We have a sender (communication initiator) and a receiver (service). When a reliable
session is constructed between the two, every message needs to come to the other side.
In a request-reply world, the sender would be a client during the request phase. Then
roles would switch during the response phase.
</p>
        <p>
The problem arises when one of the sides <strong>does not get</strong> the message
acknowledgement in time. WCF reliable messaging implementation retries the sending
process and hopes for the acknowledgement. All is well.
</p>
        <p>
The problem is that there is <em>no way </em>for the sending application to specify <em>how
long the retry timeout should be</em>. There is a way to specify channel opening and
closing timeouts, acknowledgement interval and more, but nothing will define how long
should the initiator wait for message acks.
</p>
        <p>
          <img src="http://www.request-response.com/blog/images/wcfreplytimeout1.gif" />
        </p>
        <p>
Let's talk about how WCF acknowledges messages.
</p>
        <p>
During a request-reply exchange every request message is acknowledged <em>in a response
message</em>. WS-RM SOAP headers regarding sequence definition (request) and acknowledgements
(response) look like this:
</p>
        <p>
          <font face="Courier New">a1 &lt;r:Sequence s:mustUnderstand="1" u:Id="_2"&gt;<br />
a2    &lt;r:Identifier&gt;urn:uuid:6c9d...ca90&lt;/r:Identifier&gt;<br />
a3    <strong>&lt;r:MessageNumber&gt;1&lt;/r:MessageNumber&gt;<br /></strong>a4 &lt;/r:Sequence&gt;</font>
        </p>
        <p>
          <font face="Courier New">b1 &lt;r:SequenceAcknowledgement u:Id="_3"&gt;<br />
b2    &lt;r:Identifier&gt;urn:uuid:6c99...ca290&lt;/r:Identifier&gt;<br />
b3    <strong>&lt;r:AcknowledgementRange Lower="1" Upper="1"/&gt;<br />
b4    &lt;netrm:BufferRemaining 
<br />
b5       xmlns:netrm="</strong></font>
          <font face="Courier New">
            <strong>http://schemas.microsoft.com/ws/2006/05/rm"</strong>
          </font>
          <font face="Courier New">
            <strong>&gt;<br />
b6    &lt;/netrm:BufferRemaining&gt;<br /></strong>b7 &lt;/r:SequenceAcknowledgement&gt;</font>
        </p>
        <p>
Request phase defines a sequence and sends the first message (<font face="Courier New">a3</font>).
In response, there is the appropriate acknowledgement present, which acks the first
message (<font face="Courier New">b3</font>) with <font face="Courier New">Lower</font> and <font face="Courier New">Upper</font> attributes.
Lines <font face="Courier New">b4-b6</font> define a benign and super useful WCF implementation
of <em>flow control</em>, which allows the sender to limit the rate of sent messages
if service side <strong>becomes congested</strong>.
</p>
        <p>
When the session is setup, WCF will have a really small time waiting window for acks.
Therefore, if ack is not received during this period, the infrastructure <em>will
retry the message</em>.
</p>
        <p>
Duplex contracts work slightly differently. There, the acknowledgement interval can
be set. This configuration option (config attribute is called <font face="Courier New">acknowledgementInterval</font>)
is named inappropriately, since it controls the service and not the client side.
</p>
        <p>
It does not define the time limit on <em>received acknowledgements</em>, but the necessary
time to <em>send the acknowledgments back</em>. It allows grouping of sent acks, so
that multiple incoming messages can be acked together. Also, the infrastructure will
not necessarily honor the specified value.
</p>
        <p>
Now consider the following scenario:
</p>
        <ol>
          <li>
The client is on a reliable network 
</li>
          <li>
Network bandwidth is so thin that the sending message takes 20s to come through <font face="Courier New">[1]</font></li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx">Service
instancing</a> is set to <font face="Courier New">Multiple</font></li>
          <li>
The solution uses a request-reply semantics</li>
        </ol>
        <p>
          <font size="1">
            <font face="Courier New">[1]</font> It does not matter whether the
initiator is on a dial up, or the message is huge.</font>
        </p>
        <p>
          <strong>What happens?</strong>
        </p>
        <p>
Service initiator sets up a reliable session, then:
</p>
        <ol>
          <li>
First message is being sent 
</li>
          <li>
Since the retry interval is really small <font face="Courier New">[2]</font>, the
message will not get to the other end and the acknowledgement will not bounce
back in time 
</li>
          <li>
First message is retried, now two messages are being transported 
</li>
          <li>
No acks received yet 
</li>
          <li>
First message is retried again 
</li>
          <li>
Network bandwidth is even thinner 
</li>
          <li>
First message is acknowledged 
</li>
          <li>
First message retry is discarded on the service side 
</li>
          <li>
Second message retry is discarded on the service side</li>
        </ol>
        <p>
          <font size="1">
            <font face="Courier New">[2]</font> Under 3s.</font>
        </p>
        <p>
The number of retry messages depends on the <em>bandwidth</em> and <em>message size</em>.
It can happen that tens of messages will be sent before first acknowledgement will
be received.
</p>
        <p>
          <strong>Adaptability algorithms</strong>
        </p>
        <p>
A good thing is that there are undocumented algorithms implemented for retry timeout.
The implementation increases the reply timeout <em>exponentially</em> when the infrastructure
detects that the network conditions demand more time (slow throughput) and allows
reliable delivery (no losses). If loses are present the reply timeout decreases.
</p>
        <p>
Retry timeout is actually calculated when establishing an RM session. It
is based on the roundtrip time and is bigger if the roundtrip time is long.
</p>
        <p>
So, when first messages in a session are exchanged, don't be too surprised to see
a couple of message retries.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=a510f1dc-23bb-42aa-b683-a70c4740bfe5" />
      </body>
      <title>WCF: Reliable Messaging and Retry Timeouts</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx</link>
      <pubDate>Tue, 08 Apr 2008 22:33:13 GMT</pubDate>
      <description>&lt;p&gt;
There is a &lt;em&gt;serious limitation&lt;/em&gt; present in the RTM version of WCF 3.0/3.5 regarding
control of WS-RM retry messages during a &lt;strong&gt;reliable session&lt;/strong&gt; saga.
&lt;/p&gt;
&lt;p&gt;
Let me try to explain the concept.
&lt;/p&gt;
&lt;p&gt;
We have a sender (communication initiator) and a receiver (service). When a reliable
session is constructed between the two, every message needs to come to the other side.
In a request-reply world, the sender would be a client during the request phase. Then
roles would switch during the response phase.
&lt;/p&gt;
&lt;p&gt;
The problem arises when one of the sides &lt;strong&gt;does not get&lt;/strong&gt; the message
acknowledgement in time. WCF reliable messaging implementation retries the sending
process and hopes for the acknowledgement. All is well.
&lt;/p&gt;
&lt;p&gt;
The problem is that there is &lt;em&gt;no way &lt;/em&gt;for the sending application to specify &lt;em&gt;how
long the retry timeout should be&lt;/em&gt;. There is a way to specify channel opening and
closing timeouts, acknowledgement interval and more, but nothing will define how long
should the initiator wait for message acks.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.request-response.com/blog/images/wcfreplytimeout1.gif"&gt;
&lt;/p&gt;
&lt;p&gt;
Let's talk about how WCF acknowledges messages.
&lt;/p&gt;
&lt;p&gt;
During a request-reply exchange every request message is acknowledged &lt;em&gt;in a response
message&lt;/em&gt;. WS-RM SOAP headers regarding sequence definition (request) and acknowledgements
(response) look like this:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;a1 &amp;lt;r:Sequence s:mustUnderstand="1" u:Id="_2"&amp;gt;&lt;br&gt;
a2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;r:Identifier&amp;gt;urn:uuid:6c9d...ca90&amp;lt;/r:Identifier&amp;gt;&lt;br&gt;
a3&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;&amp;lt;r:MessageNumber&amp;gt;1&amp;lt;/r:MessageNumber&amp;gt;&lt;br&gt;
&lt;/strong&gt;a4 &amp;lt;/r:Sequence&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;b1 &amp;lt;r:SequenceAcknowledgement u:Id="_3"&amp;gt;&lt;br&gt;
b2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;r:Identifier&amp;gt;urn:uuid:6c99...ca290&amp;lt;/r:Identifier&amp;gt;&lt;br&gt;
b3&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;&amp;lt;r:AcknowledgementRange Lower="1" Upper="1"/&amp;gt;&lt;br&gt;
b4&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;netrm:BufferRemaining 
&lt;br&gt;
b5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:netrm="&lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;http://schemas.microsoft.com/ws/2006/05/rm"&lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;&amp;gt;&lt;br&gt;
b6&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/netrm:BufferRemaining&amp;gt;&lt;br&gt;
&lt;/strong&gt;b7 &amp;lt;/r:SequenceAcknowledgement&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Request phase defines a sequence and sends the first message (&lt;font face="Courier New"&gt;a3&lt;/font&gt;).
In response, there is the appropriate acknowledgement present, which acks the first
message (&lt;font face="Courier New"&gt;b3&lt;/font&gt;) with &lt;font face="Courier New"&gt;Lower&lt;/font&gt; and &lt;font face="Courier New"&gt;Upper&lt;/font&gt; attributes.
Lines &lt;font face="Courier New"&gt;b4-b6&lt;/font&gt; define a benign and super useful WCF implementation
of &lt;em&gt;flow control&lt;/em&gt;, which allows the sender to limit the rate of sent messages
if service side &lt;strong&gt;becomes congested&lt;/strong&gt;.
&lt;/p&gt;
&lt;p&gt;
When the session is setup, WCF will have a really small time waiting window for acks.
Therefore, if ack is not received during this period, the infrastructure &lt;em&gt;will
retry the message&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
Duplex contracts work slightly differently. There, the acknowledgement interval can
be set. This configuration option (config attribute is called &lt;font face="Courier New"&gt;acknowledgementInterval&lt;/font&gt;)
is named inappropriately, since it controls the service and not the client side.
&lt;/p&gt;
&lt;p&gt;
It does not define the time limit on &lt;em&gt;received acknowledgements&lt;/em&gt;, but the necessary
time to &lt;em&gt;send the acknowledgments back&lt;/em&gt;. It allows grouping of sent acks, so
that multiple incoming messages can be acked together. Also, the infrastructure will
not necessarily honor the specified value.
&lt;/p&gt;
&lt;p&gt;
Now consider the following scenario:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
The client is on a reliable network 
&lt;li&gt;
Network bandwidth is so thin that the sending message takes 20s to come through &lt;font face="Courier New"&gt;[1]&lt;/font&gt; 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx"&gt;Service
instancing&lt;/a&gt; is set to &lt;font face="Courier New"&gt;Multiple&lt;/font&gt; 
&lt;li&gt;
The solution uses a request-reply semantics&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font face="Courier New"&gt;[1]&lt;/font&gt; It does not matter whether the initiator
is on a dial up, or the message is huge.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What happens?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Service initiator sets up a reliable session, then:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
First message is being sent 
&lt;li&gt;
Since the retry interval is really small &lt;font face="Courier New"&gt;[2]&lt;/font&gt;, the
message will not get to the other end and&amp;nbsp;the acknowledgement will not bounce
back in time 
&lt;li&gt;
First message is retried, now two messages are being transported 
&lt;li&gt;
No acks received yet 
&lt;li&gt;
First message is retried again 
&lt;li&gt;
Network bandwidth is even thinner 
&lt;li&gt;
First message is acknowledged 
&lt;li&gt;
First message retry is discarded on the service side 
&lt;li&gt;
Second message retry is discarded on the service side&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font face="Courier New"&gt;[2]&lt;/font&gt; Under 3s.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The number of retry messages depends on the &lt;em&gt;bandwidth&lt;/em&gt; and &lt;em&gt;message size&lt;/em&gt;.
It can happen that tens of messages will be sent before first acknowledgement will
be received.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adaptability algorithms&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
A good thing is that there are undocumented algorithms implemented for retry timeout.
The implementation increases the reply timeout &lt;em&gt;exponentially&lt;/em&gt; when the infrastructure
detects that the network conditions demand more time (slow throughput) and allows
reliable delivery (no losses). If loses are present the reply timeout decreases.
&lt;/p&gt;
&lt;p&gt;
Retry timeout is actually calculated&amp;nbsp;when establishing an&amp;nbsp;RM session.&amp;nbsp;It
is based on the roundtrip time and is bigger if the roundtrip time is long.
&lt;/p&gt;
&lt;p&gt;
So, when first messages in a session are exchanged, don't be too surprised to see
a couple of message retries.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=a510f1dc-23bb-42aa-b683-a70c4740bfe5" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,a510f1dc-23bb-42aa-b683-a70c4740bfe5.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.5 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=ff5fab81-affb-4b2b-aa67-c80bdfc86cbd</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,ff5fab81-affb-4b2b-aa67-c80bdfc86cbd.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,ff5fab81-affb-4b2b-aa67-c80bdfc86cbd.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=ff5fab81-affb-4b2b-aa67-c80bdfc86cbd</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In WCF, collection data that is passed through the service boundary goes through a <em>type
filter </em>- meaning you will not necessarily get the <em>intrinsic service side
type</em> on the client, even if you're <strong>expecting it</strong>.
</p>
        <p>
No matter if you throw back an <font face="Courier New">int[]</font> or <font face="Courier New">List&lt;int&gt;,</font> you
will get the <font face="Courier New">int[]</font> by default on the client.
</p>
        <p>
The main reason is that there is no representation for <font face="Courier New">System.Collections.Generic.List</font> or <font face="Courier New">System.Collection.Generic.LinkedList</font> in
service metadata. The concept of <font face="Courier New">System.Collection.Generic.List&lt;int&gt;</font> for
example, actually does not have a different semantic meaning from an <em>integer array</em> -
it's still a list of <em>ints</em> - but will allow you to program against it with
ease.
</p>
        <p>
Though, if one asks nicely, <strong>it is possible</strong> to guarantee the preferred
collection type on the client proxy in certain scenarios.
</p>
        <p>
Unidimensional collections, like <font face="Courier New">List&lt;T&gt;</font>, <font face="Courier New">LinkedList&lt;T&gt;</font> or <font face="Courier New">SortedList&lt;T&gt;</font> are
always exposed as <font face="Courier New">T</font> arrays in the client proxy. <font face="Courier New">Dictionary&lt;K,
V&gt;</font>, though, is regened on the client via an annotation hint in WSDL (XSD
if we are precise). More on that later.
</p>
        <p>
Let's look into it.
</p>
        <p>
WCF infrastructure bends over backwards to simplify client development. If the service
side contains a really serializable collection (marked with <font face="Courier New">[Serializable]</font>,
not <font face="Courier New">[DataContract]</font>) that is also concrete (not an
interface), and has an <font face="Courier New">Add</font> method with the following
signatures...
</p>
        <p>
          <font face="Courier New">public void Add(object obj);<br />
public void Add(T item); </font>
        </p>
        <p>
... then WCF will serialize the data to an array of the collections type.
</p>
        <p>
Too complicated? Consider the following:
</p>
        <p>
          <font face="Courier New">[ServiceContract]<br />
interface ICollect<br />
{<br />
   [OperationContract]<br />
   public void AddCoin(Coin coin);</font>
        </p>
        <p>
          <font face="Courier New">   [OperationContract]<br />
   public List&lt;Coin&gt; GetCoins();<br />
}</font>
        </p>
        <p>
Since the <font face="Courier New">List&lt;T&gt;</font> supports a <font face="Courier New">void
Add&lt;T&gt;</font> method and is marked with <font face="Courier New">[Serializable]</font>,
the following wire representation will be passed to the client:
</p>
        <p>
          <font face="Courier New">[ServiceContract]<br />
interface ICollect<br />
{<br />
  [OperationContract]<br />
  void AddCoin(Coin coin);</font>
        </p>
        <p>
          <font face="Courier New">  [OperationContract]<br />
  Coin[] GetCoins();<br />
}<br /></font>
          <font size="1">
            <br />
Note: <font face="Courier New">Coin</font> class should be marked either with a <font face="Courier New">[DataContract]</font> or <font face="Courier New">[Serializable]</font> in
this case.</font>
        </p>
        <p>
So what happens if one wants the same contract <em>on the client proxy and the service</em>?
There is an option in the WCF proxy generator, <font face="Courier New">svcutil.exe</font> to
force generation of class definitions with a specific collection type.
</p>
        <p>
Use the following for <font face="Courier New">List&lt;T&gt;</font>:
</p>
        <p>
          <font face="Courier New">svcutil.exe http://service/metadata/address<br />
  /collectionType:System.Collections.Generic.List`1<br /><br /></font>
          <font size="1">Note: <font face="Courier New">List`1</font> uses back quote,
not normal single quote character.</font>
        </p>
        <p>
What the <font face="Courier New">/collectionType</font> (short <font face="Courier New">/ct</font>)
does, is forces generation of strongly typed collection types. It will generate the
holy grail on the client:
</p>
        <p>
          <font face="Courier New">[ServiceContract]<br />
interface ICollect<br />
{<br />
  [OperationContract]<br />
  void AddCoin(Coin coin);</font>
        </p>
        <p>
          <font face="Courier New">  [OperationContract]<br />
  List&lt;Coin&gt; GetCoins();<br />
}</font>
        </p>
        <p>
In Visual Studio 2008, you will even have an option to specify which types you want
to use as <em>collection types</em> and <em>dictionary collection types</em>, as in
the following picture:
</p>
        <p>
          <img src="http://www.request-response.com/blog/images/vs2008servicereference.jpg" />
        </p>
        <p>
On the other hand, dictionary collections, as in <font face="Courier New">System.Collections.Generic.Dictionary&lt;K,
V&gt;</font> collections, will go through to the client no matter what you specify
as a <font face="Courier New">/ct</font> parameter (or don't at all).
</p>
        <p>
If you define the following on the service side...
</p>
        <p>
          <font face="Courier New">[OperationContract]<br />
Dictionary&lt;string, int&gt; GetFoo();</font>
        </p>
        <p>
... this will get generated on the client:
</p>
        <p>
          <font face="Courier New">[OperationContract]<br />
Dictionary&lt;string, int&gt; GetFoo();</font>
        </p>
        <p>
          <strong>Why?</strong>
        </p>
        <p>
Because using <font face="Courier New">System.Collections.Generic.Dictionary</font> probably
means <strong>you</strong> know there is no guarantee that client side representation
will be possible if you are using an alternative platform. There is no way to meaningfully
convey the semantics of a .NET dictionary class using WSDL/XSD. 
</p>
        <p>
          <strong>So, how does the client know?</strong>
        </p>
        <p>
In fact, the values are serialized as <strong>joined name value pair elements</strong> as
the following schema says:
</p>
        <p>
          <font face="Courier New">&lt;xs:complexType name="ArrayOfKeyValueOfstringint"&gt;<br /><font color="#a52a2a">  &lt;xs:annotation&gt;<br />
    &lt;xs:appinfo&gt;<br />
      &lt;IsDictionary<br />
        xmlns="</font></font>
          <font face="Courier New" color="#a52a2a">http://schemas.microsoft.com/2003/10/Serialization/</font>
          <font face="Courier New">
            <font color="#a52a2a">"&gt;<br />
        true<br />
      &lt;/IsDictionary&gt; 
<br />
    &lt;/xs:appinfo&gt;<br />
  &lt;/xs:annotation&gt;<br /></font>  &lt;xs:sequence&gt;<br />
    &lt;xs:element minOccurs="0" maxOccurs="unbounded"<br />
      name="KeyValueOfstringint"&gt;<br />
      &lt;xs:complexType&gt;<br />
        &lt;xs:sequence&gt;<br />
          &lt;xs:element name="Key" nillable="true"
type="xs:string" /&gt; 
<br />
          &lt;xs:element name="Value"
type="xs:int" /&gt; 
<br />
        &lt;/xs:sequence&gt;<br />
      &lt;/xs:complexType&gt;<br />
    &lt;/xs:element&gt;<br />
  &lt;/xs:sequence&gt;<br />
&lt;/xs:complexType&gt;<br />
&lt;xs:element name="ArrayOfKeyValueOfstringint"<br />
  nillable="true" type="tns:ArrayOfKeyValueOfstringint" /&gt;<br /><br /></font>
          <font size="1">Note: You can find this schema under <font face="Courier New">types</font> definition
of the metadata endpoint. Usually <font face="Courier New">?xsd=xsd2</font>, instead
of <font face="Courier New">?wsdl</font> will suffice.</font>
        </p>
        <p>
As in:
</p>
        <p>
          <font face="Courier New">&lt;GetFooResponse&gt;<br />
  &lt;KeyValueOfstringint&gt;<br />
    &lt;Key&gt;one&lt;/Key&gt;<br />
    &lt;Value&gt;1&lt;/Value&gt;</font>
        </p>
        <p>
          <font face="Courier New">    &lt;Key&gt;two&lt;/Key&gt;<br />
    &lt;Value&gt;2&lt;/Value&gt;</font>
        </p>
        <p>
          <font face="Courier New">    &lt;!-- ... --&gt;</font>
        </p>
        <p>
          <font face="Courier New">    &lt;Key&gt;N&lt;/Key&gt;<br />
    &lt;Value&gt;N&lt;/Value&gt;<br />
  &lt;/KeyValueOfstringint&gt;<br />
&lt;GetFooResponse&gt;</font>
        </p>
        <p>
The meaningful part of type service-to-client-transportation resides in <font face="Courier New">&lt;xs:annotation&gt;</font> element,
specifically in <font face="Courier New">/xs:annotation/xs:appinfo/IsDictionary</font> element,
which defines that this complex type represents a <font face="Courier New">System.Collections.Generic.Dictionary</font> class. <a href="http://www.w3.org/TR/xmlschema-0/#CommVers">Annotation</a> elements
in XML Schema are parser specific and do not convey any structure/data type semantics,
but are there <em>for the receiver to interpret</em>.
</p>
        <p>
This must be one of the <strong>most excellent school cases</strong> of using XML
Schema <a href="http://www.w3.org/TR/xmlschema-0/#CommVers">annotations</a>. It allows
the well-informed client (as in .NET client, VS 2008 or <font face="Courier New">svcutil.exe</font>)
to utilize the semantic meaning if it understands it. If not, no harm is done since
the best possible representation, in a form of joined name value pairs still goes
through to the client.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=ff5fab81-affb-4b2b-aa67-c80bdfc86cbd" />
      </body>
      <title>WCF: Passing Collections Through Service Boundaries, Why and How</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,ff5fab81-affb-4b2b-aa67-c80bdfc86cbd.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,ff5fab81-affb-4b2b-aa67-c80bdfc86cbd.aspx</link>
      <pubDate>Thu, 27 Sep 2007 21:04:47 GMT</pubDate>
      <description>&lt;p&gt;
In WCF, collection data that is passed through the service boundary goes through a &lt;em&gt;type
filter &lt;/em&gt;- meaning you will not necessarily get the &lt;em&gt;intrinsic service side
type&lt;/em&gt; on the client, even if you're &lt;strong&gt;expecting it&lt;/strong&gt;.
&lt;/p&gt;
&lt;p&gt;
No matter if you throw back an &lt;font face="Courier New"&gt;int[]&lt;/font&gt; or &lt;font face="Courier New"&gt;List&amp;lt;int&amp;gt;,&lt;/font&gt; you
will get the &lt;font face="Courier New"&gt;int[]&lt;/font&gt; by default on the client.
&lt;/p&gt;
&lt;p&gt;
The main reason is that there is no representation for &lt;font face="Courier New"&gt;System.Collections.Generic.List&lt;/font&gt; or &lt;font face="Courier New"&gt;System.Collection.Generic.LinkedList&lt;/font&gt; in
service metadata. The concept of &lt;font face="Courier New"&gt;System.Collection.Generic.List&amp;lt;int&amp;gt;&lt;/font&gt; for
example, actually does not have a different semantic meaning from an &lt;em&gt;integer array&lt;/em&gt; -
it's still a list of &lt;em&gt;ints&lt;/em&gt; - but will allow you to program against it with
ease.
&lt;/p&gt;
&lt;p&gt;
Though, if one asks nicely, &lt;strong&gt;it is possible&lt;/strong&gt; to guarantee the preferred
collection type on the client proxy in certain scenarios.
&lt;/p&gt;
&lt;p&gt;
Unidimensional collections, like &lt;font face="Courier New"&gt;List&amp;lt;T&amp;gt;&lt;/font&gt;, &lt;font face="Courier New"&gt;LinkedList&amp;lt;T&amp;gt;&lt;/font&gt; or &lt;font face="Courier New"&gt;SortedList&amp;lt;T&amp;gt;&lt;/font&gt; are
always exposed as &lt;font face="Courier New"&gt;T&lt;/font&gt; arrays in the client proxy. &lt;font face="Courier New"&gt;Dictionary&amp;lt;K,
V&amp;gt;&lt;/font&gt;, though, is regened on the client via an annotation hint in WSDL (XSD
if we are precise). More on that later.
&lt;/p&gt;
&lt;p&gt;
Let's look into it.
&lt;/p&gt;
&lt;p&gt;
WCF infrastructure bends over backwards to simplify client development. If the service
side contains a really serializable collection (marked with &lt;font face="Courier New"&gt;[Serializable]&lt;/font&gt;,
not &lt;font face="Courier New"&gt;[DataContract]&lt;/font&gt;) that is also concrete (not an
interface), and has an &lt;font face="Courier New"&gt;Add&lt;/font&gt; method with the following
signatures...
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;public void Add(object obj);&lt;br&gt;
public void Add(T item); &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
... then WCF will serialize the data to an array of the collections type.
&lt;/p&gt;
&lt;p&gt;
Too complicated? Consider the following:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[ServiceContract]&lt;br&gt;
interface ICollect&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; [OperationContract]&lt;br&gt;
&amp;nbsp;&amp;nbsp; public void AddCoin(Coin coin);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp; [OperationContract]&lt;br&gt;
&amp;nbsp;&amp;nbsp; public List&amp;lt;Coin&amp;gt; GetCoins();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Since the &lt;font face="Courier New"&gt;List&amp;lt;T&amp;gt;&lt;/font&gt; supports a &lt;font face="Courier New"&gt;void
Add&amp;lt;T&amp;gt;&lt;/font&gt; method and is marked with &lt;font face="Courier New"&gt;[Serializable]&lt;/font&gt;,
the following wire representation will be passed to the client:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[ServiceContract]&lt;br&gt;
interface ICollect&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; [OperationContract]&lt;br&gt;
&amp;nbsp; void AddCoin(Coin coin);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp; [OperationContract]&lt;br&gt;
&amp;nbsp; Coin[] GetCoins();&lt;br&gt;
}&lt;br&gt;
&lt;/font&gt;&lt;font size=1&gt;
&lt;br&gt;
Note: &lt;font face="Courier New"&gt;Coin&lt;/font&gt; class should be marked either with a &lt;font face="Courier New"&gt;[DataContract]&lt;/font&gt; or &lt;font face="Courier New"&gt;[Serializable]&lt;/font&gt; in
this case.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
So what happens if one wants the same contract &lt;em&gt;on the client proxy and the service&lt;/em&gt;?
There is an option in the WCF proxy generator, &lt;font face="Courier New"&gt;svcutil.exe&lt;/font&gt; to
force generation of class definitions with a specific collection type.
&lt;/p&gt;
&lt;p&gt;
Use the following for &lt;font face="Courier New"&gt;List&amp;lt;T&amp;gt;&lt;/font&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;svcutil.exe http://service/metadata/address&lt;br&gt;
&amp;nbsp; /collectionType:System.Collections.Generic.List`1&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font size=1&gt;Note: &lt;font face="Courier New"&gt;List`1&lt;/font&gt; uses back quote,
not normal single quote character.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
What the &lt;font face="Courier New"&gt;/collectionType&lt;/font&gt; (short &lt;font face="Courier New"&gt;/ct&lt;/font&gt;)
does, is forces generation of strongly typed collection types. It will generate the
holy grail on the client:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[ServiceContract]&lt;br&gt;
interface ICollect&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; [OperationContract]&lt;br&gt;
&amp;nbsp; void AddCoin(Coin coin);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp; [OperationContract]&lt;br&gt;
&amp;nbsp; List&amp;lt;Coin&amp;gt; GetCoins();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
In Visual Studio 2008, you will even have an option to specify which types you want
to use as &lt;em&gt;collection types&lt;/em&gt; and &lt;em&gt;dictionary collection types&lt;/em&gt;, as in
the following picture:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.request-response.com/blog/images/vs2008servicereference.jpg"&gt;
&lt;/p&gt;
&lt;p&gt;
On the other hand, dictionary collections, as in &lt;font face="Courier New"&gt;System.Collections.Generic.Dictionary&amp;lt;K,
V&amp;gt;&lt;/font&gt; collections, will go through to the client no matter what you specify
as a &lt;font face="Courier New"&gt;/ct&lt;/font&gt; parameter (or don't at all).
&lt;/p&gt;
&lt;p&gt;
If you define the following on the service side...
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[OperationContract]&lt;br&gt;
Dictionary&amp;lt;string, int&amp;gt; GetFoo();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
... this will get generated on the client:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[OperationContract]&lt;br&gt;
Dictionary&amp;lt;string, int&amp;gt; GetFoo();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Why?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Because using &lt;font face="Courier New"&gt;System.Collections.Generic.Dictionary&lt;/font&gt; probably
means &lt;strong&gt;you&lt;/strong&gt; know there is no guarantee that client side representation
will be possible if you are using an alternative platform. There is no way to meaningfully
convey the semantics of a .NET dictionary class using WSDL/XSD. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;So, how does the client know?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
In fact, the values are serialized as &lt;strong&gt;joined name value pair elements&lt;/strong&gt; as
the following schema says:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;xs:complexType name="ArrayOfKeyValueOfstringint"&amp;gt;&lt;br&gt;
&lt;font color=#a52a2a&gt;&amp;nbsp; &amp;lt;xs:annotation&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xs:appinfo&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;IsDictionary&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns="&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color=#a52a2a&gt;http://schemas.microsoft.com/2003/10/Serialization/&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#a52a2a&gt;"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; true&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/IsDictionary&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xs:appinfo&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/xs:annotation&amp;gt;&lt;br&gt;
&lt;/font&gt;&amp;nbsp; &amp;lt;xs:sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xs:element minOccurs="0" maxOccurs="unbounded"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name="KeyValueOfstringint"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xs:complexType&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xs:sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xs:element name="Key" nillable="true"
type="xs:string" /&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xs:element name="Value"
type="xs:int" /&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xs:sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xs:complexType&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xs:element&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/xs:sequence&amp;gt;&lt;br&gt;
&amp;lt;/xs:complexType&amp;gt;&lt;br&gt;
&amp;lt;xs:element name="ArrayOfKeyValueOfstringint"&lt;br&gt;
&amp;nbsp; nillable="true" type="tns:ArrayOfKeyValueOfstringint" /&amp;gt;&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font size=1&gt;Note: You can find this schema under &lt;font face="Courier New"&gt;types&lt;/font&gt; definition
of the metadata endpoint. Usually &lt;font face="Courier New"&gt;?xsd=xsd2&lt;/font&gt;, instead
of &lt;font face="Courier New"&gt;?wsdl&lt;/font&gt; will suffice.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
As in:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;GetFooResponse&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;KeyValueOfstringint&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Key&amp;gt;one&amp;lt;/Key&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;1&amp;lt;/Value&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Key&amp;gt;two&amp;lt;/Key&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;2&amp;lt;/Value&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- ... --&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Key&amp;gt;N&amp;lt;/Key&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;N&amp;lt;/Value&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/KeyValueOfstringint&amp;gt;&lt;br&gt;
&amp;lt;GetFooResponse&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The meaningful part of type service-to-client-transportation resides in &lt;font face="Courier New"&gt;&amp;lt;xs:annotation&amp;gt;&lt;/font&gt; element,
specifically in &lt;font face="Courier New"&gt;/xs:annotation/xs:appinfo/IsDictionary&lt;/font&gt; element,
which defines that this complex type represents a &lt;font face="Courier New"&gt;System.Collections.Generic.Dictionary&lt;/font&gt; class. &lt;a href="http://www.w3.org/TR/xmlschema-0/#CommVers"&gt;Annotation&lt;/a&gt; elements
in XML Schema are parser specific and do not convey any structure/data type semantics,
but are there &lt;em&gt;for the receiver to interpret&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
This must be one of the &lt;strong&gt;most excellent school cases&lt;/strong&gt; of using XML
Schema &lt;a href="http://www.w3.org/TR/xmlschema-0/#CommVers"&gt;annotations&lt;/a&gt;. It allows
the well-informed client (as in .NET client, VS 2008 or &lt;font face="Courier New"&gt;svcutil.exe&lt;/font&gt;)
to utilize the semantic meaning if it understands it. If not, no harm is done since
the best possible representation, in a form of joined name value pairs still goes
through to the client.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=ff5fab81-affb-4b2b-aa67-c80bdfc86cbd" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,ff5fab81-affb-4b2b-aa67-c80bdfc86cbd.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.5 - WCF</category>
      <category>Web Services</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=ab874bc2-1546-48d1-a8aa-46f0bf876d93</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=ab874bc2-1546-48d1-a8aa-46f0bf876d93</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm a huge fan of document style parameter models when implementing a public, programmatic <a href="http://en.wikipedia.org/wiki/Facade_pattern">façade</a> to
a business functionality that often changes.
</p>
        <p>
          <font face="Courier New">public interface IDocumentParameterModel<br />
{<br />
   [OperationContract]<br />
   [FaultContract(typeof(XmlInvalidException))]<br />
   XmlDocument Process(XmlDocument doc);<br />
}</font>
        </p>
        <p>
This contract defines a simple method, called <font face="Courier New">Process</font>,
which processes the input document. The idea is to define the <a href="http://www.w3.org/TR/xmlschema-1/">document
schema</a> and validate inbound XML documents, while throwing exceptions on <em>validation
errors</em>. The processing semantics is arbitrary and can support any kind of action,
depending on the defined <em>invoke document </em>schema.
</p>
        <p>
A simple instance document which validates against a version 1.0 <em>processing schema</em> could
look like this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0?&gt;<br />
&lt;Process xmlns="http://www.gama-system.com/process10.xsd" version="1.0"&gt;<br />
   &lt;Instruction&gt;Add&lt;/Instruction&gt;<br />
   &lt;Parameter1&gt;10&lt;/Parameter1&gt;<br />
   &lt;Parameter2&gt;21&lt;/Parameter2&gt;<br />
&lt;/Process&gt;</font>
        </p>
        <p>
Another processing instruction, supported in version 1.1 of the <em>processing schema</em>,
with different semantics could be:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0?&gt;<br />
&lt;Process xmlns="http://www.gama-system.com/process11.xsd" version="1.1"&gt;<br />
   &lt;Instruction&gt;Store&lt;/Instruction&gt;<br />
   &lt;Content&gt;77u/PEFwcGxpY2F0aW9uIHhtbG5zPSJod...mdVcCI&lt;/Content&gt;<br />
&lt;/Process&gt;</font>
        </p>
        <p>
Note that the default XML namespace changed, but that is <strong>not a norm</strong>.
It only allows you to automate schema retrieval using the schema repository (think <font face="Courier New">System.Xml.Schema.XmlSchemaSet</font>),
load all supported schemas and validate automatically.
</p>
        <p>
          <font face="Courier New">public class ProcessService : IDocumentParameterModel<br />
{<br />
   public XmlDocument Process(XmlDocument doc)<br />
   {<br />
      XmlReaderSettings sett = new XmlReaderSettings();</font>
        </p>
        <p>
          <font face="Courier New">
            <strong>      sett.Schemas.Add(&lt;document
namespace 1&gt;, &lt;schema uri 1&gt;);<br />
      ...<br />
      sett.Schemas.Add(&lt;document namespace n&gt;, &lt;schema
uri n&gt;);</strong>
          </font>
        </p>
        <p>
          <font face="Courier New">      sett.ValidationType = ValidationType.Schema;<br />
      sett.ValidationEventHandler += new 
<br />
         ValidationEventHandler(XmlInvalidHandler);<br /></font>
          <font face="Courier New">      XmlReader books = XmlReader.Create(doc.OuterXml,
sett);<br /></font>
          <font face="Courier New">      while (books.Read())
{ }</font>
        </p>
        <p>
          <font face="Courier New">      // processing goes here<br />
      ...<br />
   }</font>
        </p>
        <p>
          <font face="Courier New">   static void XmlInvalidHandler(object sender,
ValidationEventArgs e)<br />
   {<br />
      if (e.Severity == XmlSeverityType.Error)<br />
         throw new XmlInvalidException(e.Message);<br />
   }<br />
}</font>
        </p>
        <p>
The main benefit of this approach is <em>decoupling</em> the parameter model and method
processing version from the <em>communication contract</em>. A service maintainer
has an option to change the terms of processing over time, while supporting older
version-aware document instances.
</p>
        <p>
This notion is of course most beneficial in situations where your processing syntax <strong>changes
frequently</strong> and has complex validation schemas. A simple case presented here
is informational only.
</p>
        <p>
So, how do we validate?
</p>
        <ul>
          <li>
We need to check the instance document version first. This is especially true in cases
where the document is <em>not qualified with a different namespace</em> when the version
changes.</li>
          <li>
We grab the appropriate schema or schema set</li>
          <li>
We validate the inbound XML document, throw a typed <font face="Courier New">XmlInvalidException</font> if
invalid</li>
          <li>
We process the call</li>
        </ul>
        <p>
The service side is quite straightforward.
</p>
        <p>
Let's look at the <strong>client</strong> and what are the options for painless generation
of service calls using this mechanism.
</p>
        <p>
Generally, one can always produce an instance <em>invoke document</em> by hand on
the client. <em>By hand</em> meaning using <font face="Courier New">System.Xml</font> classes
and DOM concepts. Since this is higly error prone and gets tedious with increasing
complexity, there is a notion of a schema compiler, which automatically translates
your XML Schema into the CLR type system. <font face="Courier New">Xsd.exe</font> and <font face="Courier New">XmlSerializer</font> are
your friends. 
</p>
        <p>
If your schema requires parts of the instance document to be digitally signed or encrypted,
you will need to adorn the serializer output with some manual DOM work. This might
also be a reason to use the third option.
</p>
        <p>
The third, and easiest option for the general developer, is to provide a <strong>local
object model</strong>, which serializes the requests on the client. This is an example:
</p>
        <p>
          <font face="Courier New">ProcessInstruction pi = new ProcessInstruction();<br />
pi.Instruction = "Add";<br />
pi.Parameter1 = 10;<br />
pi.Parameter2 = 21;<br />
pi.Sign(cert); // pi.Encrypt(cert);<br />
pi.Serialize();<br />
proxy.Process(pi.SerializedForm);</font>
        </p>
        <p>
The main benefit of this approach comes down to having an option on the server and
the client. Client developers have three different levels of complexity for generating
service calls. The model allows them to be as close to the wire as they see fit. Or
they can be abstracted completely from the wire representation if you provide a local
object model to access your services.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=ab874bc2-1546-48d1-a8aa-46f0bf876d93" />
      </body>
      <title>Approaches to Document Style Parameter Models</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx</link>
      <pubDate>Mon, 24 Sep 2007 10:19:10 GMT</pubDate>
      <description>&lt;p&gt;
I'm a huge fan of document style parameter models when implementing a public, programmatic &lt;a href="http://en.wikipedia.org/wiki/Facade_pattern"&gt;façade&lt;/a&gt; to
a business functionality that often changes.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;public interface IDocumentParameterModel&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; [OperationContract]&lt;br&gt;
&amp;nbsp;&amp;nbsp; [FaultContract(typeof(XmlInvalidException))]&lt;br&gt;
&amp;nbsp;&amp;nbsp; XmlDocument Process(XmlDocument doc);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This contract defines a simple method, called &lt;font face="Courier New"&gt;Process&lt;/font&gt;,
which processes the input document. The idea is to define the &lt;a href="http://www.w3.org/TR/xmlschema-1/"&gt;document
schema&lt;/a&gt; and validate inbound XML documents, while throwing exceptions on &lt;em&gt;validation
errors&lt;/em&gt;. The processing semantics is arbitrary and can support any kind of action,
depending on the defined &lt;em&gt;invoke document &lt;/em&gt;schema.
&lt;/p&gt;
&lt;p&gt;
A simple instance document which validates against a version 1.0 &lt;em&gt;processing schema&lt;/em&gt; could
look like this:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;?xml version="1.0?&amp;gt;&lt;br&gt;
&amp;lt;Process xmlns="http://www.gama-system.com/process10.xsd" version="1.0"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;Instruction&amp;gt;Add&amp;lt;/Instruction&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;Parameter1&amp;gt;10&amp;lt;/Parameter1&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;Parameter2&amp;gt;21&amp;lt;/Parameter2&amp;gt;&lt;br&gt;
&amp;lt;/Process&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Another processing instruction, supported in version 1.1 of the &lt;em&gt;processing schema&lt;/em&gt;,
with different semantics could be:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;?xml version="1.0?&amp;gt;&lt;br&gt;
&amp;lt;Process xmlns="http://www.gama-system.com/process11.xsd" version="1.1"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;Instruction&amp;gt;Store&amp;lt;/Instruction&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;Content&amp;gt;77u/PEFwcGxpY2F0aW9uIHhtbG5zPSJod...mdVcCI&amp;lt;/Content&amp;gt;&lt;br&gt;
&amp;lt;/Process&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Note that the default XML namespace changed, but that is &lt;strong&gt;not a norm&lt;/strong&gt;.
It only allows you to automate schema retrieval using the schema repository (think &lt;font face="Courier New"&gt;System.Xml.Schema.XmlSchemaSet&lt;/font&gt;),
load all supported schemas and validate automatically.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;public class ProcessService : IDocumentParameterModel&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; public XmlDocument Process(XmlDocument doc)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlReaderSettings sett = new XmlReaderSettings();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sett.Schemas.Add(&amp;lt;document
namespace 1&amp;gt;, &amp;lt;schema uri 1&amp;gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sett.Schemas.Add(&amp;lt;document namespace n&amp;gt;, &amp;lt;schema
uri n&amp;gt;);&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sett.ValidationType = ValidationType.Schema;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sett.ValidationEventHandler += new 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ValidationEventHandler(XmlInvalidHandler);&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlReader books = XmlReader.Create(doc.OuterXml,
sett);&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (books.Read())
{ }&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // processing goes here&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp; static void XmlInvalidHandler(object sender,
ValidationEventArgs e)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (e.Severity == XmlSeverityType.Error)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new XmlInvalidException(e.Message);&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The main benefit of this approach is &lt;em&gt;decoupling&lt;/em&gt; the parameter model and method
processing version from the &lt;em&gt;communication contract&lt;/em&gt;. A service maintainer
has an option to change the terms of processing over time, while supporting older
version-aware document instances.
&lt;/p&gt;
&lt;p&gt;
This notion is of course most beneficial in situations where your processing syntax &lt;strong&gt;changes
frequently&lt;/strong&gt; and has complex validation schemas. A simple case presented here
is informational only.
&lt;/p&gt;
&lt;p&gt;
So, how do we validate?
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
We need to check the instance document version first. This is especially true in cases
where the document is &lt;em&gt;not qualified with a different namespace&lt;/em&gt; when the version
changes.&lt;/li&gt;
&lt;li&gt;
We grab the appropriate schema or schema set&lt;/li&gt;
&lt;li&gt;
We validate the inbound XML document, throw a typed &lt;font face="Courier New"&gt;XmlInvalidException&lt;/font&gt; if
invalid&lt;/li&gt;
&lt;li&gt;
We process the call&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The service side is quite straightforward.
&lt;/p&gt;
&lt;p&gt;
Let's look at the &lt;strong&gt;client&lt;/strong&gt; and what are the options for painless generation
of service calls using this mechanism.
&lt;/p&gt;
&lt;p&gt;
Generally, one can always produce an instance &lt;em&gt;invoke document&lt;/em&gt; by hand on
the client. &lt;em&gt;By hand&lt;/em&gt; meaning using &lt;font face="Courier New"&gt;System.Xml&lt;/font&gt; classes
and DOM concepts. Since this is higly error prone and gets tedious with increasing
complexity, there is a notion of a schema compiler, which automatically translates
your XML Schema into the CLR type system. &lt;font face="Courier New"&gt;Xsd.exe&lt;/font&gt; and &lt;font face="Courier New"&gt;XmlSerializer&lt;/font&gt; are
your friends. 
&lt;/p&gt;
&lt;p&gt;
If your schema requires parts of the instance document to be digitally signed or encrypted,
you will need to adorn the serializer output with some manual DOM work. This might
also be a reason to use the third option.
&lt;/p&gt;
&lt;p&gt;
The third, and easiest option for the general developer, is to provide a &lt;strong&gt;local
object model&lt;/strong&gt;, which serializes the requests on the client. This is an example:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;ProcessInstruction pi = new ProcessInstruction();&lt;br&gt;
pi.Instruction = "Add";&lt;br&gt;
pi.Parameter1 = 10;&lt;br&gt;
pi.Parameter2 = 21;&lt;br&gt;
pi.Sign(cert); // pi.Encrypt(cert);&lt;br&gt;
pi.Serialize();&lt;br&gt;
proxy.Process(pi.SerializedForm);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The main benefit of this approach comes down to having an option on the server and
the client. Client developers have three different levels of complexity for generating
service calls. The model allows them to be as close to the wire as they see fit. Or
they can be abstracted completely from the wire representation if you provide a local
object model to access your services.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=ab874bc2-1546-48d1-a8aa-46f0bf876d93" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,ab874bc2-1546-48d1-a8aa-46f0bf876d93.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.5 - WCF</category>
      <category>Architecture</category>
      <category>Web Services</category>
      <category>XML</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=1104ee60-c0ea-461b-b711-a289664e1f16</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,1104ee60-c0ea-461b-b711-a289664e1f16.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,1104ee60-c0ea-461b-b711-a289664e1f16.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=1104ee60-c0ea-461b-b711-a289664e1f16</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just came back from today's talk on WCF session support.
</p>
        <p>
Deliverables:
</p>
        <ul>
          <li>
            <a href="http://www.request-response.com/blog/content/binary/inetamarch2007ppt.zip">PPT</a>
          </li>
          <li>
            <a href="http://www.request-response.com/blog/content/binary/inetamarch2007.zip">Code</a>
          </li>
        </ul>
        <p>
Remember: <font face="Courier New">proxy.Close()</font> is <a href="http://www.request-response.com/blog/PermaLink,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx">your
friend</a>.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=1104ee60-c0ea-461b-b711-a289664e1f16" />
      </body>
      <title>INETA Talk: About WCF Messaging Sessions</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,1104ee60-c0ea-461b-b711-a289664e1f16.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,1104ee60-c0ea-461b-b711-a289664e1f16.aspx</link>
      <pubDate>Tue, 27 Mar 2007 18:39:27 GMT</pubDate>
      <description>&lt;p&gt;
Just came back from today's talk on WCF session support.
&lt;/p&gt;
&lt;p&gt;
Deliverables:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/content/binary/inetamarch2007ppt.zip"&gt;PPT&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/content/binary/inetamarch2007.zip"&gt;Code&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Remember: &lt;font face="Courier New"&gt;proxy.Close()&lt;/font&gt; is &lt;a href="http://www.request-response.com/blog/PermaLink,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx"&gt;your
friend&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=1104ee60-c0ea-461b-b711-a289664e1f16" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,1104ee60-c0ea-461b-b711-a289664e1f16.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=f731e5cc-9490-4f1e-bc7d-efb91f357cd1</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=f731e5cc-9490-4f1e-bc7d-efb91f357cd1</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
WCF includes support for establishing a security session through a simple configuration
attribute. The primary reason of a security session is a <em>shared security context</em> which
enables clients and services to use a faster, <strong>symmetric</strong> cryptographic
exchange.
</p>
        <p>
WCF sessions should not be thought of in terms of HTTP based sessions, since the former
are initiated by clients and the latter by the servers. In other terms, WCF sessions
are there to support some kind of shared context between a particular client and a
service. This context can be anything, and is not limited to security contexts.
</p>
        <p>
The attribute that establishes a security session and shared context is called, well, <font face="Courier New">establishSecurityContext</font> and
is present in binding configuration. An example of such a binding would be:
</p>
        <p>
          <font face="Courier New">&lt;bindings&gt;<br />
  &lt;wsHttpBinding&gt;<br />
    &lt;binding name="SecureBinding"&gt;<br />
      &lt;security mode ="Message"&gt;<br />
        &lt;message clientCredentialType="Certificate"
establishSecurityContext="true"/&gt;<br />
      &lt;/security&gt;<br />
    &lt;/binding&gt;<br />
  &lt;/wsHttpBinding&gt;<br />
&lt;bindings&gt;</font>
        </p>
        <p>
This binding allows HTTP based communication, demands message based security (think
WS-Security) and uses certificates to sign/encrypt the message content. The attribute <font face="Courier New">establishSecurityContext</font> is
set to <font face="Courier New">true</font>, which actually <em>enforces a WS-SecureConversation
session</em> between the client and the service.
</p>
        <p>
The following is a simplified version of what is going on under the covers:
</p>
        <ul>
          <li>
            <strong>Client instantiates the service proxy<br /></strong>No message exchange is taking place yet. 
</li>
          <li>
            <strong>Client requests a SCT (Secure Context Token)<br /></strong>This is done by the infrastructure, when the first service method is called.
SCT (again simplified) represents a secure context, which includes the symmetric key.
The message which demands it is (per WS-SecureConversation spec) called RST (Request
Secure Token). 
</li>
          <li>
            <strong>Service responds with RSTR (Request Secure Token Response) message<br /></strong>Session bootstraps and is ready to piggyback all further message exchanges.</li>
        </ul>
        <p>
What is not well known is that <em>there is a very low limit on the number of sessions</em> a
service is willing to accept. The default is set to 10 sessions and this was changed
(from 64) late in the WCF development cycle (summer 2006). So RTM ships with this
default.
</p>
        <p>
Service session count is greatly influenced by the instancing scheme the service is
using. Since instancing is a completely different beast, let's leave this for another
post (uhm, I already wrote something <a href="http://www.request-response.com/blog/PermaLink,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx">here</a>).
Let's just say that hitting the session problem is a non-issue when using singleton
instancing (<font face="Courier New">InstanceContextMode = InstanceContextMode.Single</font>).
</p>
        <p>
The main issue is, that most developers think of <strike>Indigo</strike> WCF services
in terms of simple request-response semantics and forget that such sessions get queued
up on the service side if you do not terminate them appropriately.
</p>
        <p>
This is the default service throttling behavior in the shipping version of WCF:
</p>
        <p>
          <font face="Courier New">&lt;behaviors&gt;<br />
  &lt;serviceBehaviors&gt;<br />
    &lt;behavior name="DefaultThrottlingBehavior"&gt;<br />
      &lt;serviceThrottling maxConcurrentCalls="16"<br />
                        
maxConcurrentSessions="10"<br />
                        
maxConcurrentInstances="&lt;Int32.MaxValue&gt;" /&gt;<br />
    &lt;/behavior&gt;<br />
  &lt;/serviceBehaviors&gt;<br />
&lt;/behaviors&gt;</font>
        </p>
        <p>
Every service is throttled, even if you don't specify it. You can, of course, <em>override
all three throttling parameters</em>.
</p>
        <p>
Sessions can only be initiated by the client. They can be explicitly terminated only
by the client. There are three ways a session can get terminated:
</p>
        <ul>
          <li>
Explicitly by the client 
</li>
          <li>
Implicitly by a timeout 
</li>
          <li>
Implicitly by errors</li>
        </ul>
        <p>
Timeout can pass on a client or a service and, if the timeout happens, the transport
channel that ensured communication gets faulted (<font face="Courier New">Channel.State
= CommunicationState.Faulted</font>). Session is also terminated if an error is detected,
thus invalidating the possibility to continue.
</p>
        <p>
Remember that every service proxy you use will demand a new session on the service
side (when using 
<br />
sessionful services). If you spawn <strong>11 threads</strong> and use a non-singleton
proxy you will cause <strong>10 sessions</strong> on the service side. The <strong>11<sup>th</sup></strong> will
not get setup and will block the client thread until the timeout expires. In this
case, the WCF infrastructure on the service side will issue a <em>warning in the trace
log</em>, but <strong>nothing will be returned to the client</strong>. It
seems as if the service would stop working. Nada.
</p>
        <p>
There is a method on every service proxy and it's there for a reason. The method is
called <font face="Courier New">Close()</font>. It closes the transport channel graciously
and terminates the security session, thus freeing up service resources. The same happens
for reliable messaging session or a combination of both.
</p>
        <p>
          <strong>Note:</strong> Another message (pair) is exchanged on <font face="Courier New">Close()</font>.
This message is saying <em>"We are done."</em> to the service. Thus, one should be
cautious when calling <font face="Courier New">Close()</font> for any exceptions,
like <font face="Courier New">CommunicationObjectFaultedException</font>.
</p>
        <p>
The best practice is to catch any <font face="Courier New">CommunicationException</font> exceptions
when closing the channel.
</p>
        <p>
To illustrate this, consider the following. You call a single method on a sessionful
service. Then hang on to the service proxy instance for an hour. The inactivity timeout
(attribute <font face="Courier New">inactivityTimeout</font> on a RM binding) is set
to 10 minutes. So, ten minutes after the first call the channel gets faulted. Then
you call <font face="Courier New">Close()</font>. This call <em>will fail</em> and
throw an exception.
</p>
        <p>
The following is the expected way of communication with sessionful services:
</p>
        <p>
          <font face="Courier New">ServiceClient proxy = new ServiceClient("&lt;Configuration&gt;");<br />
try<br />
{<br />
  // call service methods<br />
  int intSum = proxy.Add(1, 2);<br /><br /></font>
          <font face="Courier New">  // ... call all other methods ...<br /><br />
  </font>
          <font face="Courier New">// call service methods<br />
  int intSum = proxy.Subtract(1, 2);<br /><br />
  // close session<br />
  proxy.Close();<br />
}<br />
catch (TimeoutException ex)<br />
{<br />
  // handle timeout exceptions<br />
  proxy.Abort();<br />
}<br />
catch (FaultException&lt;T1&gt; ex)<br />
{<br />
  // handle typed exception T1<br />
  proxy.Close();<br />
}<br />
...<br />
catch (FaultException&lt;Tn&gt; ex)<br />
{<br />
  // handle typed exception Tn<br />
  proxy.Close();<br />
}<br />
catch (FaultException ex)<br />
{<br />
  // handle all other typed exceptions<br />
  proxy.Close();<br />
}<br />
catch (CommunicationException ex)<br />
{<br />
  // handle communication exceptions<br />
  proxy.Abort();<br />
}</font>
        </p>
        <p>
Note that using the <font face="Courier New">using</font> statement is not recommended.
The problem of <font face="Courier New">using</font> statement in this case is that
CLR automatically calls <font face="Courier New">Dispose()</font> method on the using
variable when exiting the statement. Since <font face="Courier New">Close()</font> can
fail (remember, another message is exchanged), you can miss this important exception.
</p>
        <p>
Everything in this post is true for all kinds of WCF sessions. It is <em>not limited
to security or RM sessions</em> only.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=f731e5cc-9490-4f1e-bc7d-efb91f357cd1" />
      </body>
      <title>WCF: Security Sessions and Service Throttling</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx</link>
      <pubDate>Tue, 27 Feb 2007 16:04:52 GMT</pubDate>
      <description>&lt;p&gt;
WCF includes support for establishing a security session through a simple configuration
attribute. The primary reason of a security session is a &lt;em&gt;shared security context&lt;/em&gt; which
enables clients and services to use a faster, &lt;strong&gt;symmetric&lt;/strong&gt; cryptographic
exchange.
&lt;/p&gt;
&lt;p&gt;
WCF sessions should not be thought of in terms of HTTP based sessions, since the former
are initiated by clients and the latter by the servers. In other terms, WCF sessions
are there to support some kind of shared context between a particular client and a
service. This context can be anything, and is not limited to security contexts.
&lt;/p&gt;
&lt;p&gt;
The attribute that establishes a security session and shared context is called, well, &lt;font face="Courier New"&gt;establishSecurityContext&lt;/font&gt; and
is present in binding configuration. An example of such a binding would be:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;wsHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding name="SecureBinding"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;security mode ="Message"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;message clientCredentialType="Certificate"
establishSecurityContext="true"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/wsHttpBinding&amp;gt;&lt;br&gt;
&amp;lt;bindings&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This binding allows HTTP based communication, demands message based security (think
WS-Security) and uses certificates to sign/encrypt the message content. The attribute &lt;font face="Courier New"&gt;establishSecurityContext&lt;/font&gt; is
set to &lt;font face="Courier New"&gt;true&lt;/font&gt;, which actually &lt;em&gt;enforces a WS-SecureConversation
session&lt;/em&gt; between the client and the service.
&lt;/p&gt;
&lt;p&gt;
The following is a simplified version of what is going on under the covers:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Client instantiates the service proxy&lt;br&gt;
&lt;/strong&gt;No message exchange is taking place yet. 
&lt;li&gt;
&lt;strong&gt;Client requests a SCT (Secure Context Token)&lt;br&gt;
&lt;/strong&gt;This is done by the infrastructure, when the first service method is called.
SCT (again simplified) represents a secure context, which includes the symmetric key.
The message which demands it is (per WS-SecureConversation spec) called RST (Request
Secure Token). 
&lt;li&gt;
&lt;strong&gt;Service responds with RSTR (Request Secure Token Response) message&lt;br&gt;
&lt;/strong&gt;Session bootstraps and is ready to piggyback all further message exchanges.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
What is not well known is that &lt;em&gt;there is a very low limit on the number of sessions&lt;/em&gt; a
service is willing to accept. The default is set to 10 sessions and this was changed
(from 64) late in the WCF development cycle (summer 2006). So RTM ships with this
default.
&lt;/p&gt;
&lt;p&gt;
Service session count is greatly influenced by the instancing scheme the service is
using. Since instancing is a completely different beast, let's leave this for another
post (uhm, I already wrote something &lt;a href="http://www.request-response.com/blog/PermaLink,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx"&gt;here&lt;/a&gt;).
Let's just say that hitting the session problem is a non-issue when using singleton
instancing (&lt;font face="Courier New"&gt;InstanceContextMode = InstanceContextMode.Single&lt;/font&gt;).
&lt;/p&gt;
&lt;p&gt;
The main issue is, that most developers think of &lt;strike&gt;Indigo&lt;/strike&gt; WCF services
in terms of simple request-response semantics and forget that such sessions get queued
up on the service side if you do not terminate them appropriately.
&lt;/p&gt;
&lt;p&gt;
This is the default service throttling behavior in the shipping version of WCF:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;behaviors&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;serviceBehaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name="DefaultThrottlingBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceThrottling maxConcurrentCalls="16"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
maxConcurrentSessions="10"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
maxConcurrentInstances="&amp;lt;Int32.MaxValue&amp;gt;" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behavior&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/serviceBehaviors&amp;gt;&lt;br&gt;
&amp;lt;/behaviors&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Every service is throttled, even if you don't specify it. You can, of course, &lt;em&gt;override
all three throttling parameters&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
Sessions can only be initiated by the client. They can be explicitly terminated only
by the client. There are&amp;nbsp;three ways a session can get terminated:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Explicitly by the client 
&lt;li&gt;
Implicitly by a timeout 
&lt;li&gt;
Implicitly by errors&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Timeout can pass on a client or a service and, if the timeout happens,&amp;nbsp;the transport
channel that ensured communication gets faulted (&lt;font face="Courier New"&gt;Channel.State
= CommunicationState.Faulted&lt;/font&gt;). Session is also terminated if an error is detected,
thus invalidating the possibility to continue.
&lt;/p&gt;
&lt;p&gt;
Remember that every service proxy you use will demand a new session on the service
side (when using 
&lt;br&gt;
sessionful services). If you spawn &lt;strong&gt;11 threads&lt;/strong&gt; and use a non-singleton
proxy you will cause &lt;strong&gt;10 sessions&lt;/strong&gt; on the service side. The &lt;strong&gt;11&lt;sup&gt;th&lt;/sup&gt;&lt;/strong&gt; will
not get setup and will block the client thread until the timeout expires. In this
case, the WCF infrastructure on the service side will issue a &lt;em&gt;warning in the trace
log&lt;/em&gt;, but &lt;strong&gt;nothing&amp;nbsp;will be&amp;nbsp;returned to the client&lt;/strong&gt;. It
seems as if the service would stop working. Nada.
&lt;/p&gt;
&lt;p&gt;
There is a method on every service proxy and it's there for a reason. The method is
called &lt;font face="Courier New"&gt;Close()&lt;/font&gt;. It closes the transport channel graciously
and terminates the security session, thus freeing up service resources. The same happens
for reliable messaging session or a combination of both.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Note:&lt;/strong&gt; Another message (pair) is exchanged on &lt;font face="Courier New"&gt;Close()&lt;/font&gt;.
This message is saying &lt;em&gt;"We are done."&lt;/em&gt; to the service. Thus, one should be
cautious when calling &lt;font face="Courier New"&gt;Close()&lt;/font&gt; for any exceptions,
like &lt;font face="Courier New"&gt;CommunicationObjectFaultedException&lt;/font&gt;.
&lt;/p&gt;
&lt;p&gt;
The best practice is to catch any &lt;font face="Courier New"&gt;CommunicationException&lt;/font&gt; exceptions
when closing the channel.
&lt;/p&gt;
&lt;p&gt;
To illustrate this, consider the following. You call a single method on a sessionful
service. Then hang on to the service proxy instance for an hour. The inactivity timeout
(attribute &lt;font face="Courier New"&gt;inactivityTimeout&lt;/font&gt; on a RM binding) is set
to 10 minutes. So, ten minutes after the first call the channel gets faulted. Then
you call &lt;font face="Courier New"&gt;Close()&lt;/font&gt;. This call &lt;em&gt;will fail&lt;/em&gt; and
throw an exception.
&lt;/p&gt;
&lt;p&gt;
The following is the expected way of communication with sessionful services:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;ServiceClient proxy = new ServiceClient("&amp;lt;Configuration&amp;gt;");&lt;br&gt;
try&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; // call service methods&lt;br&gt;
&amp;nbsp; int intSum = proxy.Add(1, 2);&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp; // ... call all other methods ...&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;// call service methods&lt;br&gt;
&amp;nbsp; int intSum = proxy.Subtract(1, 2);&lt;br&gt;
&lt;br&gt;
&amp;nbsp; // close session&lt;br&gt;
&amp;nbsp; proxy.Close();&lt;br&gt;
}&lt;br&gt;
catch (TimeoutException ex)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; // handle timeout exceptions&lt;br&gt;
&amp;nbsp; proxy.Abort();&lt;br&gt;
}&lt;br&gt;
catch (FaultException&amp;lt;T1&amp;gt; ex)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; // handle typed exception T1&lt;br&gt;
&amp;nbsp; proxy.Close();&lt;br&gt;
}&lt;br&gt;
...&lt;br&gt;
catch (FaultException&amp;lt;Tn&amp;gt; ex)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; // handle typed exception Tn&lt;br&gt;
&amp;nbsp; proxy.Close();&lt;br&gt;
}&lt;br&gt;
catch (FaultException ex)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; // handle all other typed exceptions&lt;br&gt;
&amp;nbsp; proxy.Close();&lt;br&gt;
}&lt;br&gt;
catch (CommunicationException ex)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; // handle communication exceptions&lt;br&gt;
&amp;nbsp; proxy.Abort();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Note that using the &lt;font face="Courier New"&gt;using&lt;/font&gt; statement is not recommended.
The problem of &lt;font face="Courier New"&gt;using&lt;/font&gt; statement in this case is that
CLR automatically calls &lt;font face="Courier New"&gt;Dispose()&lt;/font&gt; method on the using
variable when exiting the statement. Since &lt;font face="Courier New"&gt;Close()&lt;/font&gt; can
fail (remember, another message is exchanged), you can miss this important exception.
&lt;/p&gt;
&lt;p&gt;
Everything in this post is true for all kinds of WCF sessions. It is &lt;em&gt;not limited
to security or RM sessions&lt;/em&gt; only.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=f731e5cc-9490-4f1e-bc7d-efb91f357cd1" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,f731e5cc-9490-4f1e-bc7d-efb91f357cd1.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>Architecture</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=03fb0e40-b446-42b5-ad90-3be9b0260cb5</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,03fb0e40-b446-42b5-ad90-3be9b0260cb5.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,03fb0e40-b446-42b5-ad90-3be9b0260cb5.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=03fb0e40-b446-42b5-ad90-3be9b0260cb5</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm thinking about reliable messaging these days (isn't <a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx">it</a><a href="http://www.request-response.com/blog/PermaLink,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx">evident</a>?).
There are a couple of specific reasons for that. First, I can imagine a wonderful
world of seamless message delivery. Second, currently there are technology limitations
that prohibit what most of the industry would like to see.
</p>
        <p>
Let's take a look.
</p>
        <p>
There's a sentence in the <a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx">first
post</a> of the series that says:
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <em>There is no <strong>durable</strong> reliable messaging support in WCF.</em>
          </p>
        </blockquote>
        <p>
This is conditionally true. There are built-in bindings that support <em>MSMQ integration</em> and <em>use
MSMQ transport</em> as a delivery mechanism, thus making the message exchange durable.
Limitations of this approach include <em>platform dependence</em>, <em>durable store
dependence</em> and more importantly, <em>one-way messaging</em>. To implement a durable
duplex session one would need to implement two one-way service contracts. Downside?
Forget about clients sitting behing a NAT without poking holes in your firewalls.
</p>
        <p>
There are multiple uses for having durable messaging, the most prominent being different
client/service lifetimes. Why can't I dispatch a message to a service when the service
is down <strong>or</strong> I have no network connectivity?
</p>
        <p>
Reliable messaging support in WCF is designed to support <em>reliable transport</em> and
does not make any assurances of what happens to messages when they hit both <em>ends
of the wire</em>. The problem is not in the WCF implementation but rather the WS-RM
spec, which does not imply on how and when a message should/must be persisted.
</p>
        <p>
There are different implementations of durable transports or at least, <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=479#section2">some</a><a href="http://blog.yassers.com/2006/09/25/ssb-transport-anyone.aspx">people</a> are
already thinking about it. <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=479#section2">Amazon's
SQS Transport for WCF</a> is a good idea, and so is <a href="http://msdn2.microsoft.com/en-us/library/ms166043.aspx">SQL
Server SSB</a> usage... <em>if you control both ends of the wire.</em></p>
        <p>
The industry (read WS-* stack) needs a specification which will cover <strong><em>interoperable
+ durable message delivery</em></strong>. BYODS ("bring your own durable store") concept
would be efficient only when demanding a durable store on the other side of the wire,
is governed by a messaging specification.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=03fb0e40-b446-42b5-ad90-3be9b0260cb5" />
      </body>
      <title>WCF, MSMQ et al: Durable Reliable Messaging</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,03fb0e40-b446-42b5-ad90-3be9b0260cb5.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,03fb0e40-b446-42b5-ad90-3be9b0260cb5.aspx</link>
      <pubDate>Wed, 21 Feb 2007 22:25:32 GMT</pubDate>
      <description>&lt;p&gt;
I'm thinking about reliable messaging these days (isn't &lt;a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx"&gt;it&lt;/a&gt; &lt;a href="http://www.request-response.com/blog/PermaLink,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx"&gt;evident&lt;/a&gt;?).
There are a couple of specific reasons for that. First, I can imagine a wonderful
world of seamless message delivery. Second, currently there are technology limitations
that prohibit what most of the industry would like to see.
&lt;/p&gt;
&lt;p&gt;
Let's take a look.
&lt;/p&gt;
&lt;p&gt;
There's a sentence in the &lt;a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx"&gt;first
post&lt;/a&gt; of the series that says:
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;em&gt;There is no &lt;strong&gt;durable&lt;/strong&gt; reliable messaging support in WCF.&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This is conditionally true. There are built-in bindings that support &lt;em&gt;MSMQ integration&lt;/em&gt; and &lt;em&gt;use
MSMQ transport&lt;/em&gt; as a delivery mechanism, thus making the message exchange durable.
Limitations of this approach include &lt;em&gt;platform dependence&lt;/em&gt;, &lt;em&gt;durable store
dependence&lt;/em&gt; and more importantly, &lt;em&gt;one-way messaging&lt;/em&gt;. To implement a durable
duplex session one would need to implement two one-way service contracts. Downside?
Forget about clients sitting behing a NAT without poking holes in your firewalls.
&lt;/p&gt;
&lt;p&gt;
There are multiple uses for having durable messaging, the most prominent being different
client/service lifetimes. Why can't I dispatch a message to a service when the service
is&amp;nbsp;down&amp;nbsp;&lt;strong&gt;or&lt;/strong&gt; I have no network connectivity?
&lt;/p&gt;
&lt;p&gt;
Reliable messaging support in WCF is designed to support &lt;em&gt;reliable transport&lt;/em&gt; and
does not make any assurances of what happens to messages when they hit both &lt;em&gt;ends
of the wire&lt;/em&gt;. The problem is not in the WCF implementation but rather the WS-RM
spec, which does not imply on how and when a message should/must be persisted.
&lt;/p&gt;
&lt;p&gt;
There are different implementations of durable transports or at least, &lt;a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=479#section2"&gt;some&lt;/a&gt; &lt;a href="http://blog.yassers.com/2006/09/25/ssb-transport-anyone.aspx"&gt;people&lt;/a&gt; are
already thinking about it. &lt;a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=479#section2"&gt;Amazon's
SQS Transport for WCF&lt;/a&gt; is a good idea, and so is &lt;a href="http://msdn2.microsoft.com/en-us/library/ms166043.aspx"&gt;SQL
Server SSB&lt;/a&gt; usage... &lt;em&gt;if you control both ends of the wire.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
The industry (read WS-* stack) needs a specification which will cover &lt;strong&gt;&lt;em&gt;interoperable
+ durable message delivery&lt;/em&gt;&lt;/strong&gt;. BYODS ("bring your own durable store")&amp;nbsp;concept
would be efficient only when demanding a durable store on the other side of the wire,
is governed by a messaging specification.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=03fb0e40-b446-42b5-ad90-3be9b0260cb5" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,03fb0e40-b446-42b5-ad90-3be9b0260cb5.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=c9513d28-f580-4a33-b4e8-c15476799a9d</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,c9513d28-f580-4a33-b4e8-c15476799a9d.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,c9513d28-f580-4a33-b4e8-c15476799a9d.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c9513d28-f580-4a33-b4e8-c15476799a9d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Everything about WCF is about keeping your service boundary <em>intact</em>. By default
this also applies to <strong>exposing/publishing metadata</strong>. In ASMX days,
one would need to <em>opt-out</em> of exposing metadata, while in WCF, one has to <em>opt-in</em>.
</p>
        <p>
Let's say, for example, you have the following service config declaration:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
<br />
&lt;configuration&gt;<br />
  &lt;system.serviceModel&gt;<br />
    &lt;services&gt;<br />
      &lt;service name = "Exposing.Metadata"&gt;<br />
        &lt;host&gt;<br />
          &lt;baseAddresses&gt;<br />
            &lt;add baseAddress
=<br />
                
"http://localhost:123/MetadataService</font>
          <font face="Courier New">"&gt;<br />
          &lt;/baseAddresses&gt;<br />
        &lt;/host&gt;<br />
        &lt;endpoint address = ""<br />
                  binding
= "wsHttpBinding" <br />
                  contract
= "Exposing.IServiceContract"/&gt;<br />
      &lt;/service&gt;<br />
    &lt;/services&gt;<br />
  &lt;/system.serviceModel&gt;<br />
&lt;/configuration&gt;</font>
        </p>
        <p>
This would host <font face="Courier New">Exposing.Metadata</font> service and define
a single <font face="Courier New">wsHttpBinding</font> based endpoint listening at
the base address.
</p>
        <p>
So, the service endpoint address is <font face="Courier New">http://localhost:123/MetadataService</font>.
If you would hit the endpoint URL with a web browser, a nice service page would be
returned telling you that you have created a service, but there is <em>no metadata
exposed</em>. So, hitting the endpoint with <font face="Courier New">svcutil.exe</font> would
not allow you to grab metadata and generate the proxy code.
</p>
        <p>
WCF, by default, <em>does not expose any metadata</em>. You have to ask for it <em>nicely</em>.
</p>
        <p>
There are a couple of options to expose metadata of WCF services. The most basic way
of doing it would be to expose it via HTTP based Get requests and retrieve WSDL. The
following code fragment would do it, if you hosted the service using a <font face="Courier New">ServiceHost</font> class:
</p>
        <p>
          <font face="Courier New">[ 1]  using (ServiceHost sh = new ServiceHost(typeof(OpService)))<br />
[ 2]  {<br />
[ 3]   ServiceMetadataBehavior smb = new ServiceMetadataBehavior();<br />
[ 4]   smb.HttpGetEnabled = true;<br />
[ 5]   sh.Description.Behaviors.Add(smb);<br />
[ 6]   sh.Open();<br />
[ 7]   Console.WriteLine("Service running...");<br />
[ 8]<br />
[ 9]   Console.ReadLine();<br />
[10]   sh.Close();<br />
[11]  }<br /></font> <br />
Lines <font face="Courier New">3-5</font> instantiate and add a service behavior that
allows a simple HTTP Get request to succeed for metadata retrieval. Also, the mentioned
service page would now render a link to the WSDL definition of the service.
</p>
        <p>
Declarative configuration with the same effect is this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
<br />
&lt;configuration&gt;<br />
  &lt;system.serviceModel&gt;<br />
    &lt;behaviors&gt;<br />
      &lt;serviceBehaviors&gt;<br />
        &lt;behavior name = "MetadataBehavior"&gt;<br />
         &lt;serviceMetadata httpGetEnabled
= "true"/&gt;<br />
        &lt;/behavior&gt;<br />
      &lt;/serviceBehaviors&gt;<br />
    &lt;/behaviors&gt;<br />
    &lt;services&gt;<br />
      &lt;service name = "Exposing.Metadata"<br />
              
behaviorConfiguration = "MetadataBehavior"&gt;<br />
        &lt;host&gt;<br />
          &lt;baseAddresses&gt;<br />
            &lt;add baseAddress
=<br />
                
"</font>
          <font face="Courier New">http://localhost:123/MetadataService"/</font>
          <font face="Courier New">&gt;<br />
          &lt;/baseAddresses&gt;<br />
        &lt;/host&gt;<br />
        &lt;endpoint address = "" <br />
                  binding
= "wsHttpBinding" 
<br />
                 
contract = "Exposing.IServiceContract"/&gt;<br />
      &lt;/service&gt;<br />
    &lt;/services&gt;<br />
  &lt;/system.serviceModel&gt;<br />
&lt;/configuration&gt;</font>
        </p>
        <p>
We declared a behavior, called <font face="Courier New">MetadataBehavior</font> and
assigned it to our <font face="Courier New">Exposing.Metadata</font> service.
</p>
        <p>
There are a couple attributes in <font face="Courier New">&lt;serviceMetadata&gt;</font> element
worth discussing:
</p>
        <ol>
          <li>
            <font face="Courier New">externalMetadataLocation</font> allows you to specify <strong>the
path </strong>to your WSDL metadata file, so you can provide it out of band and not
rely on the infrastructure to generate it for you. 
</li>
          <li>
            <font face="Courier New">httpGetEnabled</font> exposes this metadata via <strong>HTTP
transport</strong>. 
</li>
          <li>
            <font face="Courier New">httpGetUrl</font> enables you to define a different <strong>relative </strong>WSDL
metadata endpoint address. If 'wsdl' was used, our service would expose WSDL metadata
at <font face="Courier New">http://localhost:123/MetadataService/wsdl.</font></li>
          <li>
            <font face="Courier New">httpsGetEnabled</font> allows you to expose metadata via <strong>HTTPS </strong>transport. 
</li>
          <li>
            <font face="Courier New">httpsGetUrl </font>is analog to <font face="Courier New">httpGetUrl</font> but
for HTTPS.</li>
        </ol>
        <p>
This nails down all options one would want for exposing HTTP based metadata endpoints.
</p>
        <p>
Now, exposing metadata using the WS-MetadataExchange (WS-MEX or MEX) protocol is also
opt-in. First, you have an option to include only HTTP based metadata, as described.
Second, there is a way to expose all metadata only using WS-MEX.
</p>
        <p>
Here's how, first the config file:
</p>
        <p>
          <font face="Courier New">&lt;serviceBehaviors&gt;<br />
  &lt;behavior name = "MetadataBehavior"&gt;<br />
    &lt;serviceMetadata /&gt;<br />
  &lt;/behavior&gt;<br />
&lt;/serviceBehaviors&gt;</font>
        </p>
        <p>
          <font size="1">
            <strong>
              <em>Note:</em>
            </strong> This is only the <font face="Courier New">&lt;serviceBehaviors&gt;</font> section,
not the complete service config file.</font>
        </p>
        <p>
You have to tell the hosting infrastructure to expose metadata by adding a service
behavior with the <font face="Courier New">&lt;serviceMetadata&gt;</font> element.
What this does, essentially, is add an interface called <font face="Courier New">IMetadataExchange</font> to
your contract - but does not expose it yet. You have to add a metadata endpoint to
your service and bind it to a transport of choice.
</p>
        <p>
Continuing with previous service configuration, here's what we get:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
<br />
&lt;configuration&gt;<br />
  &lt;system.serviceModel&gt;<br />
    &lt;behaviors&gt;<br />
      &lt;serviceBehaviors&gt;<br />
        &lt;behavior name = "MetadataBehavior"&gt;<br />
          &lt;serviceMetadata/&gt;<br />
        &lt;/behavior&gt;<br />
      &lt;/serviceBehaviors&gt;<br />
    &lt;/behaviors&gt;<br />
    &lt;services&gt;<br />
      &lt;service name = "Exposing.Metadata"<br />
              
behaviorConfiguration = "MetadataBehavior"&gt;<br />
        &lt;host&gt;<br />
          &lt;baseAddresses&gt;<br />
            &lt;add baseAddress
=<br />
                 "</font>
          <font face="Courier New">http://localhost:123/MetadataService"/</font>
          <font face="Courier New">&gt;<br />
          &lt;/baseAddresses&gt;<br />
        &lt;/host&gt;<br />
        &lt;endpoint address = "" 
<br />
                 
binding = "wsHttpBinding" 
<br />
                 
contract = "Exposing.IServiceContract"/&gt;<br />
        &lt;endpoint address = "mex"<br />
                 
binding = "mexHttpBinding"<br />
                 
contract = "IMetadataExchange"/&gt;<br />
      &lt;/service&gt;<br />
    &lt;/services&gt;<br />
  &lt;/system.serviceModel&gt;<br />
&lt;/configuration&gt;</font>
        </p>
        <p>
When this service is hosted, MEX metadata is exposed at <font face="Courier New">http://localhost:123/MetadataService/mex</font> and
you can reach it with <font face="Courier New">svcutil.exe</font> or 'Add Service
Reference' in Visual Studio. HTTP based WSDL access <em>is not allowed </em>since <font face="Courier New">&lt;serviceMetadata&gt;</font> element
does not include the <font face="Courier New">httpGetEnabled</font> property with
the value of <font face="Courier New">true</font>. It's <font face="Courier New">false</font> by
default, which resonates nicely in terms of WCF's opt-in scenarios.
</p>
        <p>
Remember, service orientation is about <strong>defining boundaries</strong>. And reaching
metadata about your service should be confined to <em>your choosing</em>, not the <em>platforms</em>.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=c9513d28-f580-4a33-b4e8-c15476799a9d" />
      </body>
      <title>WCF: About Exposing Metadata</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,c9513d28-f580-4a33-b4e8-c15476799a9d.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,c9513d28-f580-4a33-b4e8-c15476799a9d.aspx</link>
      <pubDate>Mon, 19 Feb 2007 13:05:46 GMT</pubDate>
      <description>&lt;p&gt;
Everything about WCF is about keeping your service boundary &lt;em&gt;intact&lt;/em&gt;. By default
this also applies to &lt;strong&gt;exposing/publishing metadata&lt;/strong&gt;. In ASMX days,
one would need to &lt;em&gt;opt-out&lt;/em&gt; of exposing metadata, while in WCF, one has to &lt;em&gt;opt-in&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
Let's say, for example, you have the following service config declaration:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt; 
&lt;br&gt;
&amp;lt;configuration&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;service name = "Exposing.Metadata"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;host&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;baseAddresses&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add baseAddress
=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
"http://localhost:123/MetadataService&lt;/font&gt;&lt;font face="Courier New"&gt;"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/baseAddresses&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/host&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address = ""&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;binding
= "wsHttpBinding"&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;contract
= "Exposing.IServiceContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/service&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/services&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/system.serviceModel&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This would host &lt;font face="Courier New"&gt;Exposing.Metadata&lt;/font&gt; service and define
a single &lt;font face="Courier New"&gt;wsHttpBinding&lt;/font&gt; based endpoint listening at
the base address.
&lt;/p&gt;
&lt;p&gt;
So, the service endpoint address is &lt;font face="Courier New"&gt;http://localhost:123/MetadataService&lt;/font&gt;.
If you would hit the endpoint URL with a web browser, a nice service page would be
returned telling you that you have created a service, but there is &lt;em&gt;no metadata
exposed&lt;/em&gt;. So, hitting the endpoint with &lt;font face="Courier New"&gt;svcutil.exe&lt;/font&gt; would
not allow you to grab metadata and generate the proxy code.
&lt;/p&gt;
&lt;p&gt;
WCF, by default, &lt;em&gt;does not expose any metadata&lt;/em&gt;. You have to ask for it &lt;em&gt;nicely&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
There are a couple of options to expose metadata of WCF services. The most basic way
of doing it would be to expose it via HTTP based Get requests and retrieve WSDL. The
following code fragment would do it, if you hosted the service using a &lt;font face="Courier New"&gt;ServiceHost&lt;/font&gt; class:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[ 1]&amp;nbsp;&amp;nbsp;using (ServiceHost sh = new ServiceHost(typeof(OpService)))&lt;br&gt;
[ 2]&amp;nbsp;&amp;nbsp;{&lt;br&gt;
[ 3]&amp;nbsp;&amp;nbsp;&amp;nbsp;ServiceMetadataBehavior smb = new ServiceMetadataBehavior();&lt;br&gt;
[ 4]&amp;nbsp;&amp;nbsp;&amp;nbsp;smb.HttpGetEnabled = true;&lt;br&gt;
[ 5]&amp;nbsp;&amp;nbsp;&amp;nbsp;sh.Description.Behaviors.Add(smb);&lt;br&gt;
[ 6]&amp;nbsp;&amp;nbsp;&amp;nbsp;sh.Open();&lt;br&gt;
[ 7]&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine("Service running...");&lt;br&gt;
[ 8]&lt;br&gt;
[ 9]&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.ReadLine();&lt;br&gt;
[10]&amp;nbsp;&amp;nbsp;&amp;nbsp;sh.Close();&lt;br&gt;
[11]&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&lt;br&gt;
Lines &lt;font face="Courier New"&gt;3-5&lt;/font&gt; instantiate and add a service behavior that
allows a simple HTTP Get request to succeed for metadata retrieval. Also, the mentioned
service page would now render a link to the WSDL definition of the service.
&lt;/p&gt;
&lt;p&gt;
Declarative configuration with the same effect is this:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt; 
&lt;br&gt;
&amp;lt;configuration&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceBehaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name = "MetadataBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceMetadata httpGetEnabled
= "true"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behavior&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/serviceBehaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/behaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;service name = "Exposing.Metadata"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
behaviorConfiguration = "MetadataBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;host&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;baseAddresses&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add baseAddress
=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
"&lt;/font&gt;&lt;font face="Courier New"&gt;http://localhost:123/MetadataService"/&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/baseAddresses&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/host&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;endpoint address = ""&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;binding
= "wsHttpBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract = "Exposing.IServiceContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/service&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/services&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/system.serviceModel&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
We declared a behavior, called &lt;font face="Courier New"&gt;MetadataBehavior&lt;/font&gt; and
assigned it to our &lt;font face="Courier New"&gt;Exposing.Metadata&lt;/font&gt; service.
&lt;/p&gt;
&lt;p&gt;
There are a couple attributes in &lt;font face="Courier New"&gt;&amp;lt;serviceMetadata&amp;gt;&lt;/font&gt; element
worth discussing:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;externalMetadataLocation&lt;/font&gt; allows you to specify &lt;strong&gt;the
path &lt;/strong&gt;to your WSDL metadata file, so you can provide it out of band and not
rely on the infrastructure to generate it for you. 
&lt;li&gt;
&lt;font face="Courier New"&gt;httpGetEnabled&lt;/font&gt; exposes this metadata via &lt;strong&gt;HTTP
transport&lt;/strong&gt;. 
&lt;li&gt;
&lt;font face="Courier New"&gt;httpGetUrl&lt;/font&gt; enables you to define a different &lt;strong&gt;relative &lt;/strong&gt;WSDL
metadata endpoint address. If 'wsdl' was used, our service would expose WSDL metadata
at &lt;font face="Courier New"&gt;http://localhost:123/MetadataService/wsdl.&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;httpsGetEnabled&lt;/font&gt; allows you to expose metadata via &lt;strong&gt;HTTPS &lt;/strong&gt;transport. 
&lt;li&gt;
&lt;font face="Courier New"&gt;httpsGetUrl &lt;/font&gt;is analog to &lt;font face="Courier New"&gt;httpGetUrl&lt;/font&gt; but
for HTTPS.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
This nails down all options one would want for exposing HTTP based metadata endpoints.
&lt;/p&gt;
&lt;p&gt;
Now, exposing metadata using the WS-MetadataExchange (WS-MEX or MEX) protocol is also
opt-in. First, you have an option to include only HTTP based metadata, as described.
Second, there is a way to expose all metadata only using WS-MEX.
&lt;/p&gt;
&lt;p&gt;
Here's how, first the config file:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;serviceBehaviors&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;behavior name = "MetadataBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceMetadata /&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/behavior&amp;gt;&lt;br&gt;
&amp;lt;/serviceBehaviors&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; This is only the &lt;font face="Courier New"&gt;&amp;lt;serviceBehaviors&amp;gt;&lt;/font&gt; section,
not the complete service config file.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
You have to tell the hosting infrastructure to expose metadata by adding a service
behavior with the &lt;font face="Courier New"&gt;&amp;lt;serviceMetadata&amp;gt;&lt;/font&gt; element.
What this does, essentially, is add an interface called &lt;font face="Courier New"&gt;IMetadataExchange&lt;/font&gt; to
your contract - but does not expose it yet. You have to add a metadata endpoint to
your service and bind it to a transport of choice.
&lt;/p&gt;
&lt;p&gt;
Continuing with previous service configuration, here's what we get:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt; 
&lt;br&gt;
&amp;lt;configuration&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceBehaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name = "MetadataBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceMetadata/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behavior&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/serviceBehaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;service name = "Exposing.Metadata"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
behaviorConfiguration = "MetadataBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;host&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;baseAddresses&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add baseAddress
=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"&lt;/font&gt;&lt;font face="Courier New"&gt;http://localhost:123/MetadataService"/&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/baseAddresses&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/host&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;endpoint address = "" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding = "wsHttpBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract = "Exposing.IServiceContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address = "mex"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding = "mexHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract = "IMetadataExchange"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/service&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/services&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/system.serviceModel&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
When this service is hosted, MEX metadata is exposed at &lt;font face="Courier New"&gt;http://localhost:123/MetadataService/mex&lt;/font&gt; and
you can reach it with &lt;font face="Courier New"&gt;svcutil.exe&lt;/font&gt; or 'Add Service
Reference' in Visual Studio. HTTP based WSDL access &lt;em&gt;is not allowed &lt;/em&gt;since &lt;font face="Courier New"&gt;&amp;lt;serviceMetadata&amp;gt;&lt;/font&gt; element
does not include the &lt;font face="Courier New"&gt;httpGetEnabled&lt;/font&gt; property with
the value of &lt;font face="Courier New"&gt;true&lt;/font&gt;. It's &lt;font face="Courier New"&gt;false&lt;/font&gt; by
default, which resonates nicely in terms of WCF's opt-in scenarios.
&lt;/p&gt;
&lt;p&gt;
Remember, service orientation is about &lt;strong&gt;defining boundaries&lt;/strong&gt;. And reaching
metadata about your service should be confined to &lt;em&gt;your choosing&lt;/em&gt;, not the &lt;em&gt;platforms&lt;/em&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=c9513d28-f580-4a33-b4e8-c15476799a9d" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,c9513d28-f580-4a33-b4e8-c15476799a9d.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=aa617aa7-1073-422c-86f5-deaaa0758e7d</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=aa617aa7-1073-422c-86f5-deaaa0758e7d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the <a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx">previous
post</a> we discussed possible scenarios and methods for configuring reliable
message delivery in WCF. Let's look further into this great WCF feature.
</p>
        <p>
Delivery assurances can have a large impact on the way your code processes incoming
messages. Especially, <em>ordering</em> can be of importance if your code relies on
ordered message delivery. Since configuration can be changed by any WCF service administrator <strong>there
is a knob in WCF which lets you demand the appropriate binding</strong>. The knob
is in a form of a declarative attribute, called <font face="Courier New">DeliveryRequirementsAttribute</font>.
</p>
        <p>
Here's how it's used:
</p>
        <p>
          <font face="Courier New">[DeliveryRequirements(RequireOrderedDelivery = true,<br /></font>
          <font face="Courier New">   QueuedDeliveryRequirements =<br />
      QueuedDeliveryRequirementsMode.Required)]<br />
interface IServiceContract<br />
{<br />
   int Operation(int a, int b);<br />
}</font>
        </p>
        <p>
          <font face="Courier New">DeliveryRequirementsAttribute </font>can be set on any service
interface or service class implementation. It has three properties:
</p>
        <ol>
          <li>
            <font face="Courier New">QueuedDeliveryRequirements</font> which has three possible
values, <font face="Courier New">Allowed</font>, <font face="Courier New">NotAllowed</font> and <font face="Courier New">Required</font>.
Setting <font face="Courier New">NotAllowed</font> or <font face="Courier New">Required</font> makes
the <strong>binding either demand or prevent</strong> WS-RM usage. Setting <font face="Courier New">Allowed</font> does
not make any requirements. 
</li>
          <li>
            <font face="Courier New">RequireOrderedDelivery</font> demands a binding that <strong>supports
and has ordered delivery turned on</strong>. 
</li>
          <li>
            <font face="Courier New">TargetContract</font> property is applicable only when the
attibute is applied to a class definition. Since WCF service interfaces can be implemented
by multiple classes, one can specify a specific interface for which the queued delivery
requirements are defined.</li>
        </ol>
        <p>
The specified contract interface would demand a WS-RM capable binding and thus prevent
service administrators to turn reliable delivery off. 
</p>
        <p>
In case where an administrator would turn reliable delivery (or ordering, in
this case) off, the service host would throw an exception while trying to
host the service.
</p>
        <p>
So, <font face="Courier New">DeliveryRequirementsAttribute</font> guards developers
from wrongdoings of service administrators. It should set <font face="Courier New">QueuedDeliveryRequirements
= QueuedDeliveryRequirementsMode.Required</font> or <font face="Courier New">RequireOrderedDelivery
= true</font>, when there are objective reasons to demand guaranteed and/or ordered
delivery of messages.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=aa617aa7-1073-422c-86f5-deaaa0758e7d" />
      </body>
      <title>WCF: Reliable Message Delivery Continued</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx</link>
      <pubDate>Mon, 19 Feb 2007 11:50:01 GMT</pubDate>
      <description>&lt;p&gt;
In the &lt;a href="http://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx"&gt;previous
post&lt;/a&gt; we discussed possible scenarios and methods for&amp;nbsp;configuring reliable
message delivery in WCF. Let's look further into this great WCF feature.
&lt;/p&gt;
&lt;p&gt;
Delivery assurances can have a large impact on the way your code processes incoming
messages. Especially, &lt;em&gt;ordering&lt;/em&gt; can be of importance if your code relies on
ordered message delivery. Since configuration can be changed by any WCF service administrator &lt;strong&gt;there
is a knob in WCF which lets you demand the appropriate binding&lt;/strong&gt;. The knob
is in a form of a declarative attribute, called &lt;font face="Courier New"&gt;DeliveryRequirementsAttribute&lt;/font&gt;.
&lt;/p&gt;
&lt;p&gt;
Here's how it's used:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[DeliveryRequirements(RequireOrderedDelivery = true,&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;QueuedDeliveryRequirements =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;QueuedDeliveryRequirementsMode.Required)]&lt;br&gt;
interface IServiceContract&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;int Operation(int a, int b);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;DeliveryRequirementsAttribute &lt;/font&gt;can be set on any service
interface or service class implementation. It has three properties:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;QueuedDeliveryRequirements&lt;/font&gt; which has three possible
values, &lt;font face="Courier New"&gt;Allowed&lt;/font&gt;, &lt;font face="Courier New"&gt;NotAllowed&lt;/font&gt; and &lt;font face="Courier New"&gt;Required&lt;/font&gt;.
Setting &lt;font face="Courier New"&gt;NotAllowed&lt;/font&gt; or &lt;font face="Courier New"&gt;Required&lt;/font&gt; makes
the &lt;strong&gt;binding either demand or prevent&lt;/strong&gt; WS-RM usage. Setting &lt;font face="Courier New"&gt;Allowed&lt;/font&gt; does
not make any requirements. 
&lt;li&gt;
&lt;font face="Courier New"&gt;RequireOrderedDelivery&lt;/font&gt; demands a binding that &lt;strong&gt;supports
and has ordered delivery turned on&lt;/strong&gt;. 
&lt;li&gt;
&lt;font face="Courier New"&gt;TargetContract&lt;/font&gt; property is applicable only when the
attibute is applied to a class definition. Since WCF service interfaces can be implemented
by multiple classes, one can specify a specific interface for which the queued delivery
requirements are defined.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
The specified contract interface would demand a WS-RM capable binding and thus prevent
service administrators to turn reliable delivery off. 
&lt;/p&gt;
&lt;p&gt;
In case where an administrator would turn reliable delivery&amp;nbsp;(or ordering, in
this case)&amp;nbsp;off,&amp;nbsp;the service host would throw an exception while trying to
host the service.
&lt;/p&gt;
&lt;p&gt;
So, &lt;font face="Courier New"&gt;DeliveryRequirementsAttribute&lt;/font&gt; guards developers
from wrongdoings of service administrators. It should set&amp;nbsp;&lt;font face="Courier New"&gt;QueuedDeliveryRequirements
= QueuedDeliveryRequirementsMode.Required&lt;/font&gt; or &lt;font face="Courier New"&gt;RequireOrderedDelivery
= true&lt;/font&gt;, when there are objective reasons to demand guaranteed and/or ordered
delivery of messages.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=aa617aa7-1073-422c-86f5-deaaa0758e7d" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,aa617aa7-1073-422c-86f5-deaaa0758e7d.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>Architecture</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://wcf.netfx3.com/">Windows Communication Foundation</a> includes concepts
which enable the developer to insist on reliably delivering messages in both directions.
The mechanism is actually transport agnostic and allows messages to be flown reliably
from client to service and replies from service to client.
</p>
        <p>
Underneath, <a href="http://www-128.ibm.com/developerworks/webservices/library/specification/ws-rm/">WS-ReliableMessaging</a> (WS-RM)
implementation is used. Click <a href="http://msdn2.microsoft.com/en-us/library/ms951271.aspx">here</a> for
Microsoft's specification. Content is the same.
</p>
        <p>
WS-RM is based on a concept of a <em>message sequence</em>. You can think of it in
terms of a session, although it does not carry HTTP session semantics (remember, it's
transport agnostic). A <em>communication initiator</em> (RM source) sends a <font face="Courier New">&lt;CreateSequence&gt;</font> element
inside the message body to establish a RM sequence. Service side (RM destination)
responds with either <font face="Courier New">&lt;CreateSequenceReponse&gt;</font> or <font face="Courier New">&lt;CreateSequenceRefused&gt;</font>,
in cases where new sequence is not welcome.
</p>
        <p>
After the sequence is initialized, there is an additional SOAP Header in messages.
It identifies the message number being transferred. The following is a simple example
of headers of the first two messages:
</p>
        <p>
          <font face="Courier New">&lt;S:Envelope&gt;<br />
   &lt;S:Header&gt;<br />
      ...<br />
      &lt;wsrm:Sequence&gt;<br />
         &lt;wsrm:Identifier&gt;http://webservices.gama-system.com/RM/Service&lt;/wsrm:Identifier&gt;<br />
         &lt;wsrm:MessageNumber&gt;1&lt;/wsrm:MessageNumber&gt;<br />
      &lt;/wsrm:Sequence&gt;<br />
   &lt;/S:Header&gt;<br />
   ...<br />
   &lt;S:Body&gt;<br />
      ...<br />
   &lt;/S:Body&gt;<br />
&lt;/S:Envelope&gt;</font>
        </p>
        <p>
          <font face="Courier New">&lt;S:Envelope&gt;<br />
   &lt;S:Header&gt;<br />
      ...<br />
      &lt;wsrm:Sequence&gt;<br />
         &lt;wsrm:Identifier&gt;http://webservices.gama-system.com/RM/Service&lt;/wsrm:Identifier&gt;<br />
         &lt;wsrm:MessageNumber&gt;2&lt;/wsrm:MessageNumber&gt;<br />
      &lt;/wsrm:Sequence&gt;<br />
   &lt;/S:Header&gt;<br />
   ...<br />
   &lt;S:Body&gt;<br />
      ...<br />
   &lt;/S:Body&gt;<br />
&lt;/S:Envelope&gt;</font>
        </p>
        <p>
After all messages have been exchanged and acknowledged, the RM destination sends
a <font face="Courier New">&lt;SequenceAcknowledgement&gt;</font> inside the body
of the message. RM source (communication initiator) then tears down the sequence with
a <font face="Courier New">&lt;TerminateSequence&gt;</font> message.
</p>
        <p>
So, how can this specification be implemented in various technology stacks? Well,
WCF implements reliable messaging using the in-memory message buffers. There is no
durable reliable messaging support in WCF.
</p>
        <p>
Here's how it works:
</p>
        <ul>
          <li>
Communication initiator (client) sends a <font face="Courier New">&lt;CreateSequence&gt;</font> message. 
</li>
          <li>
Service side responds with a <font face="Courier New">&lt;CreateSequenceResponse&gt;</font>. 
</li>
          <li>
Client sends 1..n messages and buffers them, while waiting for all acknowledgements. 
</li>
          <li>
Service side can and will dispatch the received messages as soon as possible. Now,
there are two options: 
<ul><li><strong>Communication is configured for ordered delivery<br /></strong>First message will be dispatched to the service model as soon as it arrives,
noting that it has been processed. Every other message is processed in order. If message
number 5 has been processed and the next received message carries sequence number
7, it will not be dispatched until message 6 is received and processed by the service
model. 
</li><li><strong>Communication allows out-of-order delivery<br /></strong>First message will be dispatched to the service model as soon as it arrives,
so will all the following messages. Since we did not demand ordered delivery the processing
pipeline does not care on when to process the messages. It will process them as soon
as they are received. They are acknowledged as soon as possible, but not before acknowledgement
interval.</li></ul></li>
          <li>
Service side sends a <font face="Courier New">&lt;SequenceAcknowledgement&gt;</font> message
only when all messages have been acknowledged. 
</li>
          <li>
Initiator then stops the sequence with a <font face="Courier New">&lt;TerminateSequence&gt;</font> message.</li>
        </ul>
        <p>
So, how do we go about enabling WS-RM and realizable delivery in WCF? Simple. Here's
the config file:
</p>
        <p>
          <font face="Courier New">&lt;wsHttpBinding&gt;<br />
   &lt;binding configurationName="myReliableBinding"&gt;<br />
      &lt;reliableSession enabled="true" ordered="true"
/&gt;<br />
   &lt;/binding&gt;<br />
&lt;/wsHttpBinding&gt;</font>
        </p>
        <p>
The <font face="Courier New">&lt;reliableSession&gt;</font> element has two attributes.
The first one, <font face="Courier New">enabled</font>, enables reliable message delivery.
The second one, <font face="Courier New">ordered</font>, enables in-order processing
by the service model.
</p>
        <p>
One has to acknowledge that the following is true for different WCF bindings:
</p>
        <p>
          <font face="Courier New">basicHttpBinding</font> - RM not supported<br /><font face="Courier New">wsHttpBinding</font> - RM supported, not default<br /><font face="Courier New">wsDualHttpBinding</font> - RM implicit<br /><font face="Courier New">netTcpBinding</font> - RM supported, not default
</p>
        <p>
There are a couple of options available for anyone using the custom binding, in regard
to reliable messaging behavior:
</p>
        <ol>
          <li>
            <font face="Courier New">acknowledgementInterval</font> specifies the <em>time lapse
duration </em>of message acknowledgement. The default is two seconds, while <strong>always
acknowledging the first message</strong>. This gives you an efficient way to <strong>group
the acknowledgement messages</strong>, thus conserving network traffic. 
</li>
          <li>
            <font face="Courier New">flowControlEnabled </font>enables message sender to acknowledge
the receive buffer on the recipient side. It turns out that every acknowledgement
message includes a <em>service buffer status </em>and if this attribute is set, sender
will not send messages if the recipient buffer is full, thus not occupying network
resources. 
</li>
          <li>
            <font face="Courier New">inactivityTimeout </font>defines the absolute duration of
a no-message (infrastructure and application messages) session. After the timeout,
the session is torn down. 
</li>
          <li>
            <font face="Courier New">maxPendingChannels </font>defines how many reliable channels
the service can put in its waiting-to-open queue. If there's a significant load, <strong>the
pending requests can queue up </strong>and the service refuses to open a reliable
session (think <font face="Courier New">&lt;CreateSequenceRefused&gt;</font>). 
</li>
          <li>
            <font face="Courier New">maxRetryCount</font> defaults to 8. It defines how many times
the infrastructure <strong>retries with message delivery</strong>. If the limit is
achieved, the channel will become faulted. 
</li>
          <li>
            <font face="Courier New">maxTransferWindowSize</font> defines how many messages should
be buffered. On service side all messages that have not been acknowledged <strong>increase
the count</strong>. On the client side, all messages which have not received their
acknowledgement pair <strong>are counted</strong>. 
</li>
          <li>
            <font face="Courier New">ordered</font> defines <strong>in-order delivery</strong>.
It's values are true and false.</li>
        </ol>
        <p>
There is some confusion in the <font face="Courier New">wsHttpBinding's &lt;reliableSession&gt;</font> config element.
There's an <font face="Courier New">enabled</font> property in the Visual Studio config
schema, which should not have any influence on reliable session establishment (and
does not have a matching object model method/property). It does, however. There is
a difference if you setup a reliable session by using a <font face="Courier New">customBinding</font> or <font face="Courier New">wsHttpBinding</font>.
</p>
        <p>
I.e., here's the custom binding config:
</p>
        <p>
          <font face="Courier New">&lt;customHttpBinding&gt;<br />
   &lt;binding configurationName="customReliableBinding"&gt;<br />
      &lt;reliableSession ordered="true" /&gt;<br />
   &lt;/binding&gt;<br />
&lt;/customBinding&gt;</font>
        </p>
        <p>
This will enable reliable and ordered session support in any custom binding.
</p>
        <p>
So, in general - WCF implementation of WS-ReliableMessaging gives you automatic message
retries, duplicate detection, and ordering. It should be turned on for any multi-hop
message paths, but can be very valuable even in high latency/packet loss network scenarios.
</p>
        <p>
          <strong>
            <em>Update 2007-02-19</em>
          </strong>
        </p>
        <p>
          <a href="http://www.softwaremaker.net/blog/">William Tay</a>, a friend and distributed
systems expert, replies with a terrific message exchange pattern for groking WS-RM
specification. Don't walk, <a href="http://www.softwaremaker.net/blog/WSReliableMessagingSimplifiedWHATAndHOW.aspx">run</a>.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6" />
      </body>
      <title>WCF: Reliable Message Delivery</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx</link>
      <pubDate>Sun, 18 Feb 2007 20:24:28 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://wcf.netfx3.com/"&gt;Windows Communication Foundation&lt;/a&gt; includes concepts
which enable the developer to insist on reliably delivering messages in both directions.
The mechanism is actually transport agnostic and allows messages to be flown reliably
from client to service and replies from service to client.
&lt;/p&gt;
&lt;p&gt;
Underneath, &lt;a href="http://www-128.ibm.com/developerworks/webservices/library/specification/ws-rm/"&gt;WS-ReliableMessaging&lt;/a&gt; (WS-RM)
implementation is used. Click &lt;a href="http://msdn2.microsoft.com/en-us/library/ms951271.aspx"&gt;here&lt;/a&gt; for
Microsoft's specification. Content is the same.
&lt;/p&gt;
&lt;p&gt;
WS-RM is based on a concept of a &lt;em&gt;message sequence&lt;/em&gt;. You can think of it in
terms of a session, although it does not carry HTTP session semantics (remember, it's
transport agnostic). A &lt;em&gt;communication initiator&lt;/em&gt; (RM source) sends a &lt;font face="Courier New"&gt;&amp;lt;CreateSequence&amp;gt;&lt;/font&gt; element
inside the message body to establish a RM sequence. Service side (RM destination)
responds with either &lt;font face="Courier New"&gt;&amp;lt;CreateSequenceReponse&amp;gt;&lt;/font&gt; or &lt;font face="Courier New"&gt;&amp;lt;CreateSequenceRefused&amp;gt;&lt;/font&gt;,
in cases where new sequence is not welcome.
&lt;/p&gt;
&lt;p&gt;
After the sequence is initialized, there is an additional SOAP Header in messages.
It identifies the message number being transferred. The following is a simple example
of headers of the first two messages:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;S:Envelope&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;S:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsrm:Identifier&amp;gt;http://webservices.gama-system.com/RM/Service&amp;lt;/wsrm:Identifier&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsrm:MessageNumber&amp;gt;1&amp;lt;/wsrm:MessageNumber&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/S:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;S:Body&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/S:Body&amp;gt;&lt;br&gt;
&amp;lt;/S:Envelope&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;S:Envelope&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;S:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsrm:Identifier&amp;gt;http://webservices.gama-system.com/RM/Service&amp;lt;/wsrm:Identifier&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsrm:MessageNumber&amp;gt;2&amp;lt;/wsrm:MessageNumber&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/S:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;S:Body&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/S:Body&amp;gt;&lt;br&gt;
&amp;lt;/S:Envelope&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
After all messages have been exchanged and acknowledged, the RM destination sends
a &lt;font face="Courier New"&gt;&amp;lt;SequenceAcknowledgement&amp;gt;&lt;/font&gt; inside the body
of the message. RM source (communication initiator) then tears down the sequence with
a &lt;font face="Courier New"&gt;&amp;lt;TerminateSequence&amp;gt;&lt;/font&gt; message.
&lt;/p&gt;
&lt;p&gt;
So, how can this specification be implemented in various technology stacks? Well,
WCF implements reliable messaging using the in-memory message buffers. There is no
durable reliable&amp;nbsp;messaging&amp;nbsp;support in WCF.
&lt;/p&gt;
&lt;p&gt;
Here's how it works:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Communication initiator (client) sends a &lt;font face="Courier New"&gt;&amp;lt;CreateSequence&amp;gt;&lt;/font&gt; message. 
&lt;li&gt;
Service side responds with a &lt;font face="Courier New"&gt;&amp;lt;CreateSequenceResponse&amp;gt;&lt;/font&gt;. 
&lt;li&gt;
Client sends 1..n messages and buffers them, while waiting for all acknowledgements. 
&lt;li&gt;
Service side can and will dispatch the received messages as soon as possible. Now,
there are two options: 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Communication is configured for ordered delivery&lt;br&gt;
&lt;/strong&gt;First message will be dispatched to the service model as soon as it arrives,
noting that it has been processed. Every other message is processed in order. If message
number 5 has been processed and the next received message carries sequence number
7, it will not be dispatched until message 6 is received and processed by the service
model. 
&lt;li&gt;
&lt;strong&gt;Communication allows out-of-order delivery&lt;br&gt;
&lt;/strong&gt;First message will be dispatched to the service model as soon as it arrives,
so will all the following messages. Since we did not demand ordered delivery the processing
pipeline does not care on when to process the messages. It will process them as soon
as they are received. They are acknowledged as soon as possible, but not before acknowledgement
interval.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Service side sends a &lt;font face="Courier New"&gt;&amp;lt;SequenceAcknowledgement&amp;gt;&lt;/font&gt; message
only when all messages have been acknowledged. 
&lt;li&gt;
Initiator then stops the sequence with a &lt;font face="Courier New"&gt;&amp;lt;TerminateSequence&amp;gt;&lt;/font&gt; message.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
So, how do we go about enabling WS-RM and realizable delivery in WCF? Simple. Here's
the config file:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;wsHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;binding configurationName="myReliableBinding"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;reliableSession enabled="true" ordered="true"
/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;lt;/wsHttpBinding&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The &lt;font face="Courier New"&gt;&amp;lt;reliableSession&amp;gt;&lt;/font&gt; element has two attributes.
The first one, &lt;font face="Courier New"&gt;enabled&lt;/font&gt;, enables reliable message delivery.
The second one, &lt;font face="Courier New"&gt;ordered&lt;/font&gt;, enables in-order processing
by the service model.
&lt;/p&gt;
&lt;p&gt;
One has to acknowledge that the following is true for different WCF bindings:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;basicHttpBinding&lt;/font&gt; - RM not supported&lt;br&gt;
&lt;font face="Courier New"&gt;wsHttpBinding&lt;/font&gt; - RM supported, not default&lt;br&gt;
&lt;font face="Courier New"&gt;wsDualHttpBinding&lt;/font&gt; - RM implicit&lt;br&gt;
&lt;font face="Courier New"&gt;netTcpBinding&lt;/font&gt; - RM supported, not default
&lt;/p&gt;
&lt;p&gt;
There are a couple of options available for anyone using the custom binding, in regard
to reliable messaging behavior:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;acknowledgementInterval&lt;/font&gt; specifies the &lt;em&gt;time lapse
duration &lt;/em&gt;of message acknowledgement. The default is two seconds, while &lt;strong&gt;always
acknowledging the first message&lt;/strong&gt;. This gives you an efficient way to &lt;strong&gt;group
the acknowledgement messages&lt;/strong&gt;, thus conserving network traffic. 
&lt;li&gt;
&lt;font face="Courier New"&gt;flowControlEnabled &lt;/font&gt;enables message sender to acknowledge
the receive buffer on the recipient side. It turns out that every acknowledgement
message includes a &lt;em&gt;service buffer status &lt;/em&gt;and if this attribute is set, sender
will not send messages if the recipient buffer is full, thus not occupying network
resources. 
&lt;li&gt;
&lt;font face="Courier New"&gt;inactivityTimeout &lt;/font&gt;defines the absolute duration of
a no-message (infrastructure and application messages) session. After the timeout,
the session is torn down. 
&lt;li&gt;
&lt;font face="Courier New"&gt;maxPendingChannels &lt;/font&gt;defines how many reliable channels
the service can put in its waiting-to-open queue. If there's a significant load, &lt;strong&gt;the
pending requests can queue up &lt;/strong&gt;and the service refuses to open a reliable
session (think &lt;font face="Courier New"&gt;&amp;lt;CreateSequenceRefused&amp;gt;&lt;/font&gt;). 
&lt;li&gt;
&lt;font face="Courier New"&gt;maxRetryCount&lt;/font&gt; defaults to 8. It defines how many times
the infrastructure &lt;strong&gt;retries with message delivery&lt;/strong&gt;. If the limit is
achieved, the channel will become faulted. 
&lt;li&gt;
&lt;font face="Courier New"&gt;maxTransferWindowSize&lt;/font&gt; defines how many messages should
be buffered. On service side all messages that have not been acknowledged &lt;strong&gt;increase
the count&lt;/strong&gt;. On the client side, all messages which have not received their
acknowledgement pair &lt;strong&gt;are counted&lt;/strong&gt;. 
&lt;li&gt;
&lt;font face="Courier New"&gt;ordered&lt;/font&gt; defines &lt;strong&gt;in-order delivery&lt;/strong&gt;.
It's values are true and false.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
There is some confusion in the &lt;font face="Courier New"&gt;wsHttpBinding's &amp;lt;reliableSession&amp;gt;&lt;/font&gt; config&amp;nbsp;element.
There's an &lt;font face="Courier New"&gt;enabled&lt;/font&gt; property in the Visual Studio config
schema, which should not have any influence on reliable session establishment (and
does not have a matching object model method/property). It does, however. There is
a difference if you setup a reliable session by using a &lt;font face="Courier New"&gt;customBinding&lt;/font&gt; or &lt;font face="Courier New"&gt;wsHttpBinding&lt;/font&gt;.
&lt;/p&gt;
&lt;p&gt;
I.e., here's the custom binding config:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;customHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;binding configurationName="customReliableBinding"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;reliableSession ordered="true" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;lt;/customBinding&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This will enable reliable and ordered session support in any custom binding.
&lt;/p&gt;
&lt;p&gt;
So, in general - WCF implementation of WS-ReliableMessaging gives you automatic message
retries, duplicate detection, and ordering. It should be turned on for any multi-hop
message paths, but can be very valuable even in high latency/packet loss network scenarios.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;em&gt;Update 2007-02-19&lt;/em&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.softwaremaker.net/blog/"&gt;William Tay&lt;/a&gt;, a friend and distributed
systems expert, replies with a terrific message exchange pattern for groking WS-RM
specification. Don't walk, &lt;a href="http://www.softwaremaker.net/blog/WSReliableMessagingSimplifiedWHATAndHOW.aspx"&gt;run&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,a6cb59e6-cbc2-4ce3-92b2-ea40bc5929f6.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>Architecture</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=970f2ea8-2c17-4ece-b80e-e131afdd9f5f</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,970f2ea8-2c17-4ece-b80e-e131afdd9f5f.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,970f2ea8-2c17-4ece-b80e-e131afdd9f5f.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=970f2ea8-2c17-4ece-b80e-e131afdd9f5f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Third incarnation of the .NET 3.0 Middleware Technologies day went through yesterday.
</p>
        <p>
Here are the deliverables:
</p>
        <ul>
          <li>
PPT: <a href="http://www.request-response.com/blog/content/binary/WCF_WF_Feb2007_3.zip">Download</a> [1] 
</li>
          <li>
WCF Samples: <a href="http://www.request-response.com/blog/content/binary/WCFDemosFeb2007_3.zip">Download</a></li>
          <li>
WF Samples: <a href="http://www.request-response.com/blog/content/binary/WFDemosFeb2007_3.zip">Download</a></li>
        </ul>
        <p>
If you did not get/notice the printed articles, here's what should put you to sleep
over the weekend:
</p>
        <ul>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,25e8d68b-09ff-46e8-b360-ecd5128aa90c.aspx">Concepts
and Semantics of Service Contracts</a> [1] 
</li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620.aspx">Transactional
Semantics in Loosely Coupled Distributed Systems</a> [1] 
</li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,86bd92f2-13fd-4454-ab88-272a4a8be875.aspx">Cooperation Between
Workflows and Services</a> [1] 
</li>
          <li>
            <a href="http://www.request-response.com/blog/PermaLink,guid,baaf6646-162a-4557-9d7e-10e4953ab627.aspx">Type
Systems Compared - XML &lt;&gt; CLR</a> [1]</li>
        </ul>
        <p>
Also, the accompanying book is available <a href="http://www.request-response.com/blog/PermaLink,guid,2f86ca0f-29fa-48b0-b761-ca147ada43dd.aspx">here</a>.
</p>
        <p>
          <font color="#808080" size="1">[1] Only available in Slovene.</font>
        </p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=970f2ea8-2c17-4ece-b80e-e131afdd9f5f" />
      </body>
      <title>.NET 3.0 Middleware Technologies Day: Third Incarnation</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,970f2ea8-2c17-4ece-b80e-e131afdd9f5f.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,970f2ea8-2c17-4ece-b80e-e131afdd9f5f.aspx</link>
      <pubDate>Thu, 15 Feb 2007 05:09:56 GMT</pubDate>
      <description>&lt;p&gt;
Third incarnation of the .NET 3.0 Middleware Technologies day went through yesterday.
&lt;/p&gt;
&lt;p&gt;
Here are the deliverables:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
PPT: &lt;a href="http://www.request-response.com/blog/content/binary/WCF_WF_Feb2007_3.zip"&gt;Download&lt;/a&gt;&amp;nbsp;[1] 
&lt;li&gt;
WCF Samples: &lt;a href="http://www.request-response.com/blog/content/binary/WCFDemosFeb2007_3.zip"&gt;Download&lt;/a&gt; 
&lt;li&gt;
WF Samples: &lt;a href="http://www.request-response.com/blog/content/binary/WFDemosFeb2007_3.zip"&gt;Download&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
If you did not get/notice the printed articles, here's what should put you to sleep
over the weekend:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,25e8d68b-09ff-46e8-b360-ecd5128aa90c.aspx"&gt;Concepts
and Semantics of Service Contracts&lt;/a&gt;&amp;nbsp;[1] 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620.aspx"&gt;Transactional
Semantics in Loosely Coupled Distributed Systems&lt;/a&gt;&amp;nbsp;[1] 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,86bd92f2-13fd-4454-ab88-272a4a8be875.aspx"&gt;Cooperation&amp;nbsp;Between
Workflows and Services&lt;/a&gt;&amp;nbsp;[1] 
&lt;li&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,baaf6646-162a-4557-9d7e-10e4953ab627.aspx"&gt;Type
Systems Compared - XML &amp;lt;&amp;gt; CLR&lt;/a&gt;&amp;nbsp;[1]&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Also, the accompanying book is available &lt;a href="http://www.request-response.com/blog/PermaLink,guid,2f86ca0f-29fa-48b0-b761-ca147ada43dd.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#808080 size=1&gt;[1] Only available in Slovene.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=970f2ea8-2c17-4ece-b80e-e131afdd9f5f" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,970f2ea8-2c17-4ece-b80e-e131afdd9f5f.aspx</comments>
      <category>.NET 3.0 - General</category>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.0 - WF</category>
      <category>Architecture</category>
      <category>Transactions</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=a17ce68f-d603-4eef-b6df-39a9162ca835</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,a17ce68f-d603-4eef-b6df-39a9162ca835.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,a17ce68f-d603-4eef-b6df-39a9162ca835.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a17ce68f-d603-4eef-b6df-39a9162ca835</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://channel9.msdn.com/showpost.aspx?postid=256597">This</a> must be one
of the best <a href="http://channel9.msdn.com">Channel 9</a> interviews of all time.
</p>
        <p>
          <a href="http://www.neopoleon.com">Rory</a> did make quite an effort to handle the
guys, but at building <a href="http://en.wikipedia.org/wiki/The_Answer_to_Life%2C_the_Universe%2C_and_Everything">42</a>,
what can you expect.
</p>
        <p>
It all seems as the <a href="http://en.wikipedia.org/wiki/Brady_Bunch">Brady Bunch</a> of
Microsoft on tape, but they sure did ship the most important Microsoft technology
stack of the decade.
</p>
        <p>
Well done on both parts.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=a17ce68f-d603-4eef-b6df-39a9162ca835" />
      </body>
      <title>WCF: Serious Seriousness</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,a17ce68f-d603-4eef-b6df-39a9162ca835.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,a17ce68f-d603-4eef-b6df-39a9162ca835.aspx</link>
      <pubDate>Mon, 13 Nov 2006 23:03:26 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://channel9.msdn.com/showpost.aspx?postid=256597"&gt;This&lt;/a&gt; must be one
of the best &lt;a href="http://channel9.msdn.com"&gt;Channel 9&lt;/a&gt; interviews of all time.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.neopoleon.com"&gt;Rory&lt;/a&gt; did make quite an effort to handle the
guys, but at building &lt;a href="http://en.wikipedia.org/wiki/The_Answer_to_Life%2C_the_Universe%2C_and_Everything"&gt;42&lt;/a&gt;,
what can you expect.
&lt;/p&gt;
&lt;p&gt;
It all seems as the &lt;a href="http://en.wikipedia.org/wiki/Brady_Bunch"&gt;Brady Bunch&lt;/a&gt; of
Microsoft on tape, but they sure did ship the most important Microsoft technology
stack of the decade.
&lt;/p&gt;
&lt;p&gt;
Well done on both parts.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=a17ce68f-d603-4eef-b6df-39a9162ca835" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,a17ce68f-d603-4eef-b6df-39a9162ca835.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=9c42242b-1d7c-4864-aa64-ab72dbf27ada</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,9c42242b-1d7c-4864-aa64-ab72dbf27ada.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,9c42242b-1d7c-4864-aa64-ab72dbf27ada.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9c42242b-1d7c-4864-aa64-ab72dbf27ada</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I just finished presenting my talk on the October 2006 Slovenian MSDN event.
</p>
        <p>
Here are the deliverables:
</p>
        <p>
Code: <a href="http://www.request-response.com/blog/content/binary/CalculateTaxServiceWorkflow.zip">Download</a><br />
PPT: <a href="http://www.request-response.com/blog/content/binary/WCF+WF_Oct2006.zip">Download</a> [Slovenian]
</p>
        <p>
Solution file includes:
</p>
        <ol>
          <li>
WCF service using <font face="Courier New">wsDualHttpBinding</font> for duplex session
communication scenario. WCF service hosts a workflow which computes stock tax based
on the current (complex) Slovenian legislation.</li>
          <li>
WF workflow named <font face="Courier New">ComputeTaxWorkflow</font><font face="Verdana">.
Workflow calls out to our public ASP .NET WebServices: <a href="http://webservices.gama-system.com/stockquotes.asmx">StockQuotes</a> and <a href="http://webservices.gama-system.com/exchangerates.asmx">ExchangeRates</a>.</font></li>
          <li>
WCF Client, which sends requests and receives responses when the workflow is done</li>
        </ol>
        <p>
Check it out. It's free.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=9c42242b-1d7c-4864-aa64-ab72dbf27ada" />
      </body>
      <title>MSDN Event Presentation: Code and PPT</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,9c42242b-1d7c-4864-aa64-ab72dbf27ada.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,9c42242b-1d7c-4864-aa64-ab72dbf27ada.aspx</link>
      <pubDate>Mon, 23 Oct 2006 10:04:56 GMT</pubDate>
      <description>&lt;p&gt;
I just finished presenting my talk on the October 2006 Slovenian MSDN event.
&lt;/p&gt;
&lt;p&gt;
Here are the deliverables:
&lt;/p&gt;
&lt;p&gt;
Code: &lt;a href="http://www.request-response.com/blog/content/binary/CalculateTaxServiceWorkflow.zip"&gt;Download&lt;/a&gt;
&lt;br&gt;
PPT: &lt;a href="http://www.request-response.com/blog/content/binary/WCF+WF_Oct2006.zip"&gt;Download&lt;/a&gt;&amp;nbsp;[Slovenian]
&lt;/p&gt;
&lt;p&gt;
Solution file includes:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
WCF service using &lt;font face="Courier New"&gt;wsDualHttpBinding&lt;/font&gt; for duplex session
communication scenario. WCF service hosts a workflow which computes stock tax based
on the current (complex) Slovenian legislation.&lt;/li&gt;
&lt;li&gt;
WF workflow named &lt;font face="Courier New"&gt;ComputeTaxWorkflow&lt;/font&gt;&lt;font face=Verdana&gt;.
Workflow calls out to our public ASP .NET WebServices: &lt;a href="http://webservices.gama-system.com/stockquotes.asmx"&gt;StockQuotes&lt;/a&gt; and &lt;a href="http://webservices.gama-system.com/exchangerates.asmx"&gt;ExchangeRates&lt;/a&gt;.&lt;/font&gt;
&lt;/li&gt;
&lt;li&gt;
WCF Client, which sends requests and receives responses when the workflow is done&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Check it out. It's free.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=9c42242b-1d7c-4864-aa64-ab72dbf27ada" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,9c42242b-1d7c-4864-aa64-ab72dbf27ada.aspx</comments>
      <category>.NET 3.0 - General</category>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.0 - WF</category>
      <category>Work</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=4c9487e9-b98a-48ae-902a-f08b8c56f9fd</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,4c9487e9-b98a-48ae-902a-f08b8c56f9fd.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,4c9487e9-b98a-48ae-902a-f08b8c56f9fd.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4c9487e9-b98a-48ae-902a-f08b8c56f9fd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We had a nice discussion throughout the day today, together with around 50 attendees.
It's hard to even cover feature changes of .NET 3.0 in a day, but we managed
to cover the important things of WCF and WF, spending a complete day inside the Visual
Studio.
</p>
        <p>
Here are the demos: <a href="http://www.request-response.com/blog/content/binary/WCFWFDemosOct2006.zip">Download</a><br />
And the PPT slides: <a href="http://www.request-response.com/blog/content/binary/WCF_WF_Oct2006.zip">Download</a> [Slovenian]
</p>
        <p>
And the link to the Tom Archer's <a href="http://blogs.msdn.com/tomarcher/archive/2006/07/17/668572.aspx">compatibility
matrix</a> for the .NET Framework 3.0 downloads.
</p>
        <p>
Thanks to everyone who attended.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=4c9487e9-b98a-48ae-902a-f08b8c56f9fd" />
      </body>
      <title>.NET 3.0 Middleware Technologies Day</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,4c9487e9-b98a-48ae-902a-f08b8c56f9fd.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,4c9487e9-b98a-48ae-902a-f08b8c56f9fd.aspx</link>
      <pubDate>Thu, 05 Oct 2006 17:03:06 GMT</pubDate>
      <description>&lt;p&gt;
We had a nice discussion throughout the day today, together with around 50 attendees.
It's hard to even&amp;nbsp;cover feature changes of .NET 3.0 in a day, but we managed
to cover the important things of WCF and WF, spending a complete day inside the Visual
Studio.
&lt;/p&gt;
&lt;p&gt;
Here are the demos: &lt;a href="http://www.request-response.com/blog/content/binary/WCFWFDemosOct2006.zip"&gt;Download&lt;/a&gt;
&lt;br&gt;
And the PPT slides: &lt;a href="http://www.request-response.com/blog/content/binary/WCF_WF_Oct2006.zip"&gt;Download&lt;/a&gt;&amp;nbsp;[Slovenian]
&lt;/p&gt;
&lt;p&gt;
And the link to the Tom Archer's&amp;nbsp;&lt;a href="http://blogs.msdn.com/tomarcher/archive/2006/07/17/668572.aspx"&gt;compatibility
matrix&lt;/a&gt; for the .NET Framework 3.0 downloads.
&lt;/p&gt;
&lt;p&gt;
Thanks to everyone who attended.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=4c9487e9-b98a-48ae-902a-f08b8c56f9fd" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,4c9487e9-b98a-48ae-902a-f08b8c56f9fd.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.0 - WF</category>
      <category>Architecture</category>
      <category>Work</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=86bd92f2-13fd-4454-ab88-272a4a8be875</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,86bd92f2-13fd-4454-ab88-272a4a8be875.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,86bd92f2-13fd-4454-ab88-272a4a8be875.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=86bd92f2-13fd-4454-ab88-272a4a8be875</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Last article discusses service-workflow cooperation options in <a href="http://msdn.microsoft.com/winfx/">WinFX</a> and
dives into communication scenarios for <a href="http://www.windowsworkflow.net/">Windows
Workflow Foundation</a>.
</p>
        <p>
Language: <strong><em>Slovenian</em></strong></p>
        <hr />
        <p>
Naslov:
</p>
        <p>
          <a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-WorkflowsServices.doc">Sodelovanje
storitev in delovnih tokov</a>
        </p>
        <p>
          <em>
            <a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-WorkflowsServices.doc">
              <img alt="Sodelovanje storitev in delovnih tokov" hspace="0" src="http://www.request-response.com/blog/images/matevzgacnik-workflowsservices.jpg" align="baseline" border="1" />
            </a>
          </em>
        </p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=86bd92f2-13fd-4454-ab88-272a4a8be875" />
      </body>
      <title>Article: Cooperation Between Workflows and Services</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,86bd92f2-13fd-4454-ab88-272a4a8be875.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,86bd92f2-13fd-4454-ab88-272a4a8be875.aspx</link>
      <pubDate>Wed, 07 Jun 2006 09:29:02 GMT</pubDate>
      <description>&lt;p&gt;
Last article discusses&amp;nbsp;service-workflow cooperation&amp;nbsp;options in &lt;a href="http://msdn.microsoft.com/winfx/"&gt;WinFX&lt;/a&gt; and
dives into communication scenarios for &lt;a href="http://www.windowsworkflow.net/"&gt;Windows
Workflow Foundation&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Language:&amp;nbsp;&lt;strong&gt;&lt;em&gt;Slovenian&lt;/em&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;
Naslov:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-WorkflowsServices.doc"&gt;Sodelovanje
storitev in delovnih tokov&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&lt;a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-WorkflowsServices.doc"&gt;&lt;img alt="Sodelovanje storitev in delovnih tokov" hspace=0 src="http://www.request-response.com/blog/images/matevzgacnik-workflowsservices.jpg" align=baseline border=1&gt;&lt;/a&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=86bd92f2-13fd-4454-ab88-272a4a8be875" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,86bd92f2-13fd-4454-ab88-272a4a8be875.aspx</comments>
      <category>Articles</category>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.0 - WF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.request-response.com/blog/PermaLink,guid,e77d7831-b76f-4750-a650-1503b425467e.aspx">Last
article</a> finished my XML series. This one focuses on transactional semantics in
a service oriented universe.
</p>
        <p>
Language: <strong><em>Slovenian</em></strong></p>
        <hr />
        <p>
Naslov:
</p>
        <p>
          <a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-TransactionalServices.doc">Transakcijska
semantika v šibko sklopljenih, porazdeljenih sistemih</a>
        </p>
        <p>
          <em>
            <a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-TransactionalServices.doc">
              <img alt="Transakcijska semantika v šibko sklopljenih, porazdeljenih sistemih" hspace="0" src="http://www.request-response.com/blog/images/matevzgacnik-TransactionalServices.jpg" align="baseline" border="1" />
            </a>
          </em>
        </p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620" />
      </body>
      <title>Article: Transactional Semantics in Loosely Coupled Distributed Systems</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620.aspx</link>
      <pubDate>Tue, 06 Jun 2006 08:59:30 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.request-response.com/blog/PermaLink,guid,e77d7831-b76f-4750-a650-1503b425467e.aspx"&gt;Last
article&lt;/a&gt; finished my XML series. This one focuses on transactional semantics in
a service oriented universe.
&lt;/p&gt;
&lt;p&gt;
Language:&amp;nbsp;&lt;strong&gt;&lt;em&gt;Slovenian&lt;/em&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;
Naslov:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-TransactionalServices.doc"&gt;Transakcijska
semantika v šibko sklopljenih, porazdeljenih sistemih&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&lt;a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-TransactionalServices.doc"&gt;&lt;img alt="Transakcijska semantika v šibko sklopljenih, porazdeljenih sistemih" hspace=0 src="http://www.request-response.com/blog/images/matevzgacnik-TransactionalServices.jpg" align=baseline border=1&gt;&lt;/a&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,a40bf4fb-fea6-42c5-a2f2-f0e7dafa3620.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>Architecture</category>
      <category>Articles</category>
      <category>Transactions</category>
      <category>Web Services</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=25e8d68b-09ff-46e8-b360-ecd5128aa90c</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,25e8d68b-09ff-46e8-b360-ecd5128aa90c.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,25e8d68b-09ff-46e8-b360-ecd5128aa90c.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=25e8d68b-09ff-46e8-b360-ecd5128aa90c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The second article is about concepts and semantics of service contracts. It deals
with WCF (<a href="http://www.windowscommunication.net">Windows Communication Foundation</a>)
contract definition and its behavioral aspects.
</p>
        <p>
Language: <strong><em>Slovenian</em></strong></p>
        <hr />
        <p>
Naslov:
</p>
        <p>
          <a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-ServiceContracts.doc">Koncepti
in semantike storitvenih pogodb</a>
        </p>
        <p>
          <em>
            <a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-ServiceContracts.doc">
              <img alt="Koncepti in semantike storitvenih pogodb" hspace="0" src="http://www.request-response.com/blog/images/matevzgacnik-servicecontracts.jpg" align="baseline" border="1" />
            </a>
          </em>
        </p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=25e8d68b-09ff-46e8-b360-ecd5128aa90c" />
      </body>
      <title>Article: Concepts and Semantics of Service Contracts</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,25e8d68b-09ff-46e8-b360-ecd5128aa90c.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,25e8d68b-09ff-46e8-b360-ecd5128aa90c.aspx</link>
      <pubDate>Fri, 02 Jun 2006 18:19:45 GMT</pubDate>
      <description>&lt;p&gt;
The second article is about concepts and semantics of service contracts. It deals
with WCF (&lt;a href="http://www.windowscommunication.net"&gt;Windows Communication Foundation&lt;/a&gt;)
contract definition and its behavioral aspects.
&lt;/p&gt;
&lt;p&gt;
Language:&amp;nbsp;&lt;strong&gt;&lt;em&gt;Slovenian&lt;/em&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;
Naslov:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-ServiceContracts.doc"&gt;Koncepti
in semantike storitvenih pogodb&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&lt;a href="http://www.request-response.com/blog/content/binary/MatevzGacnik-ServiceContracts.doc"&gt;&lt;img alt="Koncepti in semantike storitvenih pogodb" hspace=0 src="http://www.request-response.com/blog/images/matevzgacnik-servicecontracts.jpg" align=baseline border=1&gt;&lt;/a&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=25e8d68b-09ff-46e8-b360-ecd5128aa90c" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,25e8d68b-09ff-46e8-b360-ecd5128aa90c.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>Architecture</category>
      <category>Articles</category>
      <category>Web Services</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=c3e15d02-a74b-4ed4-a282-925342bdaddc</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,c3e15d02-a74b-4ed4-a282-925342bdaddc.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,c3e15d02-a74b-4ed4-a282-925342bdaddc.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c3e15d02-a74b-4ed4-a282-925342bdaddc</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Having the ability to call services from inside your workflows is a good thing. Things
get a little obfuscated when one wants to expose a WCF based service to Windows Workflow
Foundation (WF).
</p>
        <p>
What it comes down to is that currently (beta 2 build of WF) we do not have any built-in
workflow activities which would allow you to communicate with the WCF advanced services
(meaning WS-Security enabled, TCP based, WS-RM enabled, WS-Tx enabled, ...).
</p>
        <p>
Assuming we have an <font face="Courier New">OrderService</font> exposed using the
following config:
</p>
        <p>
          <font face="Courier New">&lt;configuration&gt;<br />
  &lt;system.serviceModel&gt;<br />
    &lt;bindings&gt;<br />
      &lt;wsHttpBinding&gt;<br /><font color="#a52a2a">        &lt;binding name="Default"&gt;<br />
          &lt;security mode="None"/&gt;<br />
        &lt;/binding&gt;<br />
        &lt;binding name="Secure"&gt;<br />
          &lt;security mode="Message"&gt;<br />
            &lt;message clientCredentialType="Windows"/&gt;<br />
          &lt;/security&gt;<br />
        &lt;/binding&gt;<br />
        &lt;binding name="Reliable"&gt;<br />
          &lt;reliableSession enabled="true"
ordered="true"/&gt;<br />
        &lt;/binding&gt;<br /></font>      &lt;/wsHttpBinding&gt;<br />
    &lt;/bindings&gt;<br />
    &lt;services&gt;<br />
      &lt;service name="WCFCalledByWorkflow.OrderService"
&gt;<br /><font color="#a52a2a">        &lt;endpoint address=""<br />
                 
binding="wsHttpBinding"<br />
                 
behaviorConfiguration="Default"<br />
                 
contract="WCFCalledByWorkflow.IOrderService" /&gt;<br />
        &lt;endpoint address="/secure"<br />
                 
binding="wsHttpBinding"<br />
                 
behaviorConfiguration="Secure"<br />
                 
contract="WCFCalledByWorkflow.IOrderService" /&gt;<br />
        &lt;endpoint address="/reliable"<br />
                 
binding="wsHttpBinding"<br />
                 
behaviorConfiguration="Reliable"<br />
                 
contract="WCFCalledByWorkflow.IOrderService" /&gt;<br /></font>      &lt;/service&gt;<br />
    &lt;/services&gt;<br />
  &lt;/system.serviceModel&gt;<br />
&lt;/configuration&gt;</font>
        </p>
        <p>
This, combined with the following hosting app:
</p>
        <p>
          <font face="Courier New">using (ServiceHost sh = new ServiceHost(typeof(OrderService),<br />
   </font>
          <font face="Courier New">new Uri("</font>
          <font face="Courier New">http://localhost:666/OrderService</font>
          <font face="Courier New">")))<br />
{<br />
   sh.Open();<br />
   Console.WriteLine("Order service running..\n");<br />
   Console.WriteLine("Listening on:");<br /><font color="#a52a2a">   foreach(ServiceEndpoint se in sh.Description.Endpoints)<br />
   {<br />
      Console.WriteLine(se.Address.ToString());<br />
   }<br /></font>   Console.WriteLine("\nPress [Enter] to stop the service.");<br />
   Console.ReadLine();<br />
   sh.Close();<br />
}</font>
        </p>
        <p>
Would produce the following output when run:
</p>
        <p>
          <font face="Courier New">Order service running..</font>
        </p>
        <p>
          <font face="Courier New">Listening on:<br /></font>
          <font color="#a52a2a">
            <font face="Courier New">http://localhost:666/OrderService</font>
            <br />
            <font face="Courier New">http://localhost:666/OrderService/secure</font>
            <br />
            <font face="Courier New">http://localhost:666/OrderService/reliable</font>
          </font>
        </p>
        <p>
          <font face="Courier New">Press [Enter] to stop the service.</font>
        </p>
        <p>
Now, this is not enough. Our service exposes three different endpoints, each one has
different message requirements. And what is more important, all three are based on
SOAP 1.2 + WS-Addressing.
</p>
        <p>
There is a 'Default' endpoint which is plain vanilla SOAP 1.2 endpoint, without any
security (have to mention it: WCF services <em>are secure by default</em>, one has
to <em>turn off security</em> to achive this). Second endpoint uses Windows based
message security and third turns on WS-RM. Security wise, second and third endpoints
are the same (remember, defaults?).
</p>
        <p>
As said, WF is currently not able to communicate with any of the above endpoints.
What needs to be done is adding another endpoint to your service, which would expose
it in ASMX compatible way.
</p>
        <p>
The new config is this:
</p>
        <p>
          <font face="Courier New">&lt;configuration&gt;<br />
  &lt;system.serviceModel&gt;<br />
    &lt;bindings&gt;<br />
      &lt;wsHttpBinding&gt;<br />
        &lt;binding name="Default"&gt;<br />
          &lt;security mode="None"/&gt;<br />
        &lt;/binding&gt;<br />
        &lt;binding name="Secure"&gt;<br />
          &lt;security mode="Message"&gt;<br />
            &lt;message clientCredentialType="Windows"/&gt;<br />
          &lt;/security&gt;<br />
        &lt;/binding&gt;<br />
        &lt;binding name="Reliable"&gt;<br />
          &lt;reliableSession enabled="true"
ordered="true"/&gt;<br />
        &lt;/binding&gt;<br />
      &lt;/wsHttpBinding&gt;<br />
    &lt;/bindings&gt;<br />
    &lt;services&gt;<br />
      &lt;service name="WCFCalledByWorkflow.OrderService"
&gt;<br />
        &lt;endpoint address=""<br />
                 
binding="wsHttpBinding"<br />
                 
behaviorConfiguration="Default"<br />
                 
contract="WCFCalledByWorkflow.IOrderService" /&gt;<br />
        &lt;endpoint address="/secure"<br />
                 
binding="wsHttpBinding"<br />
                 
behaviorConfiguration="Secure"<br />
                 
contract="WCFCalledByWorkflow.IOrderService" /&gt;<br />
        &lt;endpoint address="/reliable"<br />
                 
binding="wsHttpBinding"<br />
                 
behaviorConfiguration="Reliable"<br />
                 
contract="WCFCalledByWorkflow.IOrderService" /&gt;<br /><font color="#a52a2a">        &lt;endpoint address="/legacy"<br />
                 
binding="basicHttpBinding"<br />
                 
contract="WCFCalledByWorkflow.IOrderService"/&gt;<br /></font>      &lt;/service&gt;<br />
    &lt;/services&gt;<br />
  &lt;/system.serviceModel&gt;<br />
&lt;/configuration&gt;</font>
        </p>
        <p>
So our Windows Workflow Foundation compatible endpoint is <font face="Courier New">&lt;base
address&gt;/legacy</font>. 
</p>
        <p>
What this means is that you can bind all your <font face="Courier New">InvokeWebService</font> activities
inside workflows to published WCF services by just adding another ASMX compatible
endpoint to the WCF service.
</p>
        <p>
The difference in two WCF configs is here:
</p>
        <p>
          <font face="Courier New">&lt;endpoint address="/legacy"<br />
   binding="basicHttpBinding"<br />
   contract="WCFCalledByWorkflow.IOrderService"<br /></font>
          <font face="Courier New">/&gt;</font>
        </p>
        <p>
Code sample can be downloaded <a href="http://www.request-response.com/blog/content/binary/workflowinvokingwcf.zip">here</a>.
It includes two projects, a WF and a WCF project. <font face="Courier New">ServiceHost</font> is
implemented.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=c3e15d02-a74b-4ed4-a282-925342bdaddc" />
      </body>
      <title>Windows Workflow Foundation: Calling WCF Services</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,c3e15d02-a74b-4ed4-a282-925342bdaddc.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,c3e15d02-a74b-4ed4-a282-925342bdaddc.aspx</link>
      <pubDate>Wed, 31 May 2006 10:54:58 GMT</pubDate>
      <description>&lt;p&gt;
Having the ability to call services from inside your workflows is a good thing. Things
get a little obfuscated when one wants to expose a WCF based service to Windows Workflow
Foundation (WF).
&lt;/p&gt;
&lt;p&gt;
What it comes down to is that currently (beta 2 build of WF) we do not have any built-in
workflow activities which would allow you to communicate with the WCF advanced services
(meaning WS-Security enabled, TCP based, WS-RM enabled, WS-Tx enabled, ...).
&lt;/p&gt;
&lt;p&gt;
Assuming we have an &lt;font face="Courier New"&gt;OrderService&lt;/font&gt; exposed using the
following config:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;configuration&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsHttpBinding&amp;gt;&lt;br&gt;
&lt;font color=#a52a2a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding name="Default"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;security mode="None"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding name="Secure"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;security mode="Message"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;message clientCredentialType="Windows"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding name="Reliable"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;reliableSession enabled="true"
ordered="true"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;service name="WCFCalledByWorkflow.OrderService"
&amp;gt;&lt;br&gt;
&lt;font color=#a52a2a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address=""&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="wsHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
behaviorConfiguration="Default"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="WCFCalledByWorkflow.IOrderService" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address="/secure"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="wsHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
behaviorConfiguration="Secure"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="WCFCalledByWorkflow.IOrderService" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address="/reliable"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="wsHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
behaviorConfiguration="Reliable"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="WCFCalledByWorkflow.IOrderService" /&amp;gt;&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/service&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/services&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/system.serviceModel&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This, combined with the following hosting app:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;using (ServiceHost sh = new ServiceHost(typeof(OrderService),&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font face="Courier New"&gt;new Uri("&lt;/font&gt;&lt;font face="Courier New"&gt;http://localhost:666/OrderService&lt;/font&gt;&lt;font face="Courier New"&gt;")))&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; sh.Open();&lt;br&gt;
&amp;nbsp;&amp;nbsp; Console.WriteLine("Order service running..\n");&lt;br&gt;
&amp;nbsp;&amp;nbsp; Console.WriteLine("Listening on:");&lt;br&gt;
&lt;font color=#a52a2a&gt;&amp;nbsp;&amp;nbsp; foreach(ServiceEndpoint se in sh.Description.Endpoints)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(se.Address.ToString());&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp; Console.WriteLine("\nPress [Enter] to stop the service.");&lt;br&gt;
&amp;nbsp;&amp;nbsp; Console.ReadLine();&lt;br&gt;
&amp;nbsp;&amp;nbsp; sh.Close();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Would produce the following output when run:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;Order service running..&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;Listening on:&lt;br&gt;
&lt;/font&gt;&lt;font color=#a52a2a&gt;&lt;font face="Courier New"&gt;http://localhost:666/OrderService&lt;/font&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;http://localhost:666/OrderService/secure&lt;/font&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;http://localhost:666/OrderService/reliable&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;Press [Enter] to stop the service.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Now, this is not enough. Our service exposes three different endpoints, each one has
different message requirements. And what is more important, all three are based on
SOAP 1.2 + WS-Addressing.
&lt;/p&gt;
&lt;p&gt;
There is a 'Default' endpoint which is plain vanilla SOAP 1.2 endpoint, without any
security (have to mention it: WCF services &lt;em&gt;are secure by default&lt;/em&gt;, one has
to &lt;em&gt;turn off security&lt;/em&gt; to achive this). Second endpoint uses Windows based
message security and third turns on WS-RM. Security wise, second and third endpoints
are the same (remember, defaults?).
&lt;/p&gt;
&lt;p&gt;
As said, WF is currently not able to communicate with any of the above endpoints.
What needs to be done is adding another endpoint to your service, which would expose
it in ASMX compatible way.
&lt;/p&gt;
&lt;p&gt;
The new config is this:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;configuration&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding name="Default"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;security mode="None"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding name="Secure"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;security mode="Message"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;message clientCredentialType="Windows"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding name="Reliable"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;reliableSession enabled="true"
ordered="true"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;service name="WCFCalledByWorkflow.OrderService"
&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address=""&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="wsHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
behaviorConfiguration="Default"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="WCFCalledByWorkflow.IOrderService" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address="/secure"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="wsHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
behaviorConfiguration="Secure"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="WCFCalledByWorkflow.IOrderService" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address="/reliable"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="wsHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
behaviorConfiguration="Reliable"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="WCFCalledByWorkflow.IOrderService" /&amp;gt;&lt;br&gt;
&lt;font color=#a52a2a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address="/legacy"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="basicHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="WCFCalledByWorkflow.IOrderService"/&amp;gt;&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/service&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/services&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/system.serviceModel&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
So our Windows Workflow Foundation compatible endpoint is &lt;font face="Courier New"&gt;&amp;lt;base
address&amp;gt;/legacy&lt;/font&gt;. 
&lt;/p&gt;
&lt;p&gt;
What this means is that you can bind all your &lt;font face="Courier New"&gt;InvokeWebService&lt;/font&gt; activities
inside workflows to published WCF services by just adding another ASMX compatible
endpoint to the WCF service.
&lt;/p&gt;
&lt;p&gt;
The difference in two WCF configs is here:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;endpoint address="/legacy"&lt;br&gt;
&amp;nbsp;&amp;nbsp; binding="basicHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp; contract="WCFCalledByWorkflow.IOrderService"&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;/&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Code sample can be downloaded &lt;a href="http://www.request-response.com/blog/content/binary/workflowinvokingwcf.zip"&gt;here&lt;/a&gt;.
It includes two projects, a WF and a WCF project. &lt;font face="Courier New"&gt;ServiceHost&lt;/font&gt; is
implemented.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=c3e15d02-a74b-4ed4-a282-925342bdaddc" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,c3e15d02-a74b-4ed4-a282-925342bdaddc.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.0 - WF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=4b5f46cd-3c15-4213-9570-1a235c4a615e</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,4b5f46cd-3c15-4213-9570-1a235c4a615e.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,4b5f46cd-3c15-4213-9570-1a235c4a615e.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4b5f46cd-3c15-4213-9570-1a235c4a615e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In <a href="http://www.windowscommunication.net/">WCF</a> there's a knob which you
can turn to configure service credential propagation semantics.
</p>
        <p>
It's called <font face="Courier New">negotiateServiceCredential</font> and is present
in <font face="Courier New">bindings/&lt;bindingOfChoice&gt;/binding/security/message/@negotiateServiceCredential</font> in
the WCF configuration schema.
</p>
        <p>
This would be a possible use of it, considering only the bindings section of the WCF
configuration file:
</p>
        <p>
          <font face="Courier New">&lt;bindings&gt;<br />
   &lt;wsHttpBinding&gt;<br />
      &lt;binding name="MySecureBinding"&gt;<br />
         &lt;security mode ="Message"&gt;<br />
            &lt;message <strong>clientCredentialType="Certificate"
negotiateServiceCredential="false"</strong>/&gt;<br />
         &lt;/security&gt;<br />
      &lt;/binding&gt;<br />
   &lt;/wsHttpBinding&gt;<br />
&lt;/bindings&gt;</font>
        </p>
        <p>
Due to the value of <font face="Courier New">false</font>, the specified config would
mandate that the WCF clients need to obtain the service credential (in this case,
an X.509 certificate) out of band. Out of band in this situation means that the client
needs to have a service side certificate in one of its certificate stores.
</p>
        <p>
If one would put <font face="Courier New">negotiateServiceCredential="true"</font> in
the upper configuration file this would not be necessary. Indigo would start with
a SPNego protocol to exchange the service credentials using startup messages. For
the client side, this is good in certain situations, where you would not want to (or
were unable to) store service side credentials on the client. The major drawback is
that this forces you to use SPNego during initialization phase and it forces you to
do it <em>every time</em> you start up the client.
</p>
        <p>
If the <font face="Courier New">clientCredentialType </font>attribute equals to <font face="Courier New">Anonymous</font>, <font face="Courier New">Username</font>,
or <font face="Courier New">Certificate</font>, setting this attribute to <font face="Courier New">false </font>implies
that the client needs to define the <font face="Courier New">serviceCertificate</font> attribute.
The following would be a valid config value for having <font face="Courier New">clientCrendentialType="Certificate"<font face="Verdana"> (again,
limiting it to only the </font>behavior</font> element:
</p>
        <p>
          <font face="Courier New">&lt;behavior name="MyBehavior"&gt;<br />
   &lt;serviceCredentials&gt;<br />
      &lt;serviceCertificate<br />
         x509FindType="FindBySubjectName"<br />
         findValue="&lt;My Certificate
Subject&gt;"<br />
         storeLocation="LocalMachine"<br />
         storeName="My"/&gt;<br />
   &lt;/serviceCredentials&gt;<br />
&lt;/behavior&gt;</font>
        </p>
        <p>
As a reminder, the default value of <font face="Courier New">negotiateServiceCredential</font> attribute
is <font face="Courier New">true</font>.
</p>
        <p>
To put all this into perspective, this is a possible WCF config file:
</p>
        <p>
          <font face="Courier New">
            <font face="Courier New">&lt;system.serviceModel&gt;<br />
   </font>
            <font face="Courier New">&lt;bindings&gt;<br />
      &lt;wsHttpBinding&gt;<br />
         &lt;binding name="MySecureBinding"&gt;<br />
            &lt;security
mode ="Message"&gt;<br />
               &lt;message
clientCredentialType="Certificate" negotiateServiceCredential="false"/&gt;<br />
            &lt;/security&gt;<br />
         &lt;/binding&gt;<br />
      &lt;/wsHttpBinding&gt;<br />
   &lt;/bindings&gt;<br />
   </font>
            <font face="Courier New">&lt;behavior name="MyBehavior"&gt;<br />
      &lt;serviceCredentials&gt;<br />
         &lt;serviceCertificate<br />
            x509FindType="FindBySubjectName"<br />
            findValue="MyCertSubject"<br />
            storeLocation="LocalMachine"<br />
            storeName="My"/&gt;<br />
      &lt;/serviceCredentials&gt;<br />
   &lt;/behavior&gt;<br />
   </font>&lt;services&gt;<br />
      &lt;service name="MyService" behaviorConfiguration="MyBehavior"&gt;<br />
         &lt;endpoint address="" binding="wsHttpBinding"<br />
            </font>
          <font face="Courier New">bindingConfiguration="MySecureBinding" contract="MyNamespace.MyContract"/&gt;<br /></font>
          <font face="Courier New">      &lt;/service&gt;<br />
   &lt;/services&gt;<br />
&lt;/system.serviceModel&gt;</font>
        </p>
        <p>
This config file mandates that the client has service credentials available out of
band. Specifically it should be available in the local machine certificate store.
The certificate should have a substring of <font face="Courier New">MyCertSubject</font> inside
its subject. If this is not the case, one would not be able to call the service successfully.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=4b5f46cd-3c15-4213-9570-1a235c4a615e" />
      </body>
      <title>Windows Communication Foundation: negotiateServiceCredential attribute</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,4b5f46cd-3c15-4213-9570-1a235c4a615e.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,4b5f46cd-3c15-4213-9570-1a235c4a615e.aspx</link>
      <pubDate>Sat, 13 May 2006 21:56:04 GMT</pubDate>
      <description>&lt;p&gt;
In &lt;a href="http://www.windowscommunication.net/"&gt;WCF&lt;/a&gt; there's a knob which you
can turn to configure service credential propagation semantics.
&lt;/p&gt;
&lt;p&gt;
It's called &lt;font face="Courier New"&gt;negotiateServiceCredential&lt;/font&gt; and is present
in &lt;font face="Courier New"&gt;bindings/&amp;lt;bindingOfChoice&amp;gt;/binding/security/message/@negotiateServiceCredential&lt;/font&gt; in
the WCF configuration schema.
&lt;/p&gt;
&lt;p&gt;
This would be a possible use of it, considering only the bindings section of the WCF
configuration file:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;binding name="MySecureBinding"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;security mode ="Message"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;message &lt;strong&gt;clientCredentialType="Certificate"
negotiateServiceCredential="false"&lt;/strong&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/wsHttpBinding&amp;gt;&lt;br&gt;
&amp;lt;/bindings&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Due to the value of &lt;font face="Courier New"&gt;false&lt;/font&gt;, the specified config would
mandate that the WCF clients need to obtain the service credential (in this case,
an X.509 certificate) out of band. Out of band in this situation means that the client
needs to have a service side certificate in&amp;nbsp;one of its certificate stores.
&lt;/p&gt;
&lt;p&gt;
If&amp;nbsp;one would&amp;nbsp;put &lt;font face="Courier New"&gt;negotiateServiceCredential="true"&lt;/font&gt; in
the upper configuration file this would not be necessary. Indigo would start with
a SPNego protocol to exchange the service credentials using startup messages. For
the client side, this is good in certain situations, where you would not want to (or
were unable to) store service side credentials on the client. The major drawback is
that this forces you to use SPNego during initialization phase and it forces you to
do it &lt;em&gt;every time&lt;/em&gt; you start up the client.
&lt;/p&gt;
&lt;p&gt;
If the &lt;font face="Courier New"&gt;clientCredentialType &lt;/font&gt;attribute equals to &lt;font face="Courier New"&gt;Anonymous&lt;/font&gt;, &lt;font face="Courier New"&gt;Username&lt;/font&gt;,
or &lt;font face="Courier New"&gt;Certificate&lt;/font&gt;, setting this attribute to &lt;font face="Courier New"&gt;false &lt;/font&gt;implies
that the client needs to&amp;nbsp;define the &lt;font face="Courier New"&gt;serviceCertificate&lt;/font&gt; attribute.
The following would be a valid config value for having &lt;font face="Courier New"&gt;clientCrendentialType="Certificate"&lt;font face=Verdana&gt; (again,
limiting it to only the &lt;/font&gt;behavior&lt;/font&gt; element:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;behavior name="MyBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;serviceCredentials&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;serviceCertificate&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x509FindType="FindBySubjectName"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;findValue="&amp;lt;My Certificate
Subject&amp;gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;storeLocation="LocalMachine"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;storeName="My"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/serviceCredentials&amp;gt;&lt;br&gt;
&amp;lt;/behavior&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
As a reminder, the default value of &lt;font face="Courier New"&gt;negotiateServiceCredential&lt;/font&gt; attribute
is &lt;font face="Courier New"&gt;true&lt;/font&gt;.
&lt;/p&gt;
&lt;p&gt;
To put all this into perspective, this is a possible WCF config file:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font face="Courier New"&gt;&amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;binding name="MySecureBinding"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;security
mode ="Message"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;message
clientCredentialType="Certificate" negotiateServiceCredential="false"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/wsHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;lt;behavior name="MyBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;serviceCredentials&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;serviceCertificate&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x509FindType="FindBySubjectName"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;findValue="MyCertSubject"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;storeLocation="LocalMachine"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;storeName="My"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/serviceCredentials&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/behavior&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;service name="MyService" behaviorConfiguration="MyBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;endpoint address="" binding="wsHttpBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;bindingConfiguration="MySecureBinding"&amp;nbsp;contract="MyNamespace.MyContract"/&amp;gt;&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/service&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/services&amp;gt;&lt;br&gt;
&amp;lt;/system.serviceModel&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This config file mandates that the client has service credentials available out of
band. Specifically it should be available in the local machine certificate store.
The certificate should have a substring of &lt;font face="Courier New"&gt;MyCertSubject&lt;/font&gt; inside
its subject. If this is not the case, one would not be able to call the service successfully.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=4b5f46cd-3c15-4213-9570-1a235c4a615e" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,4b5f46cd-3c15-4213-9570-1a235c4a615e.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=21c95c2c-63d7-44f6-8357-1be0ecb6f264</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,21c95c2c-63d7-44f6-8357-1be0ecb6f264.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,21c95c2c-63d7-44f6-8357-1be0ecb6f264.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=21c95c2c-63d7-44f6-8357-1be0ecb6f264</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There are currently a couple of options to expose a Windows Workflow as as service.
</p>
        <ol>
          <li>
There is a native option to publish a developed Workflow Library project as a ASP
.NET Web Service (ASMX). 
</li>
          <li>
You can host it yourself (ASMX, WCF) 
</li>
          <li>
            <a href="http://www.softwaremaker.net/blog/">William Tay</a> is doing excellent work
towards <a href="http://www.softwaremaker.net/blog/HookingAWorkflowIntoYourWCFDispatcher.aspx">hosting
a workflow inside the WCF service pipeline</a> (WCF) 
</li>
          <li>
            <a href="http://www.codeproject.com/script/profile/whos_who.asp?vt=arts&amp;id=24570">Roman
Kiss</a> created a <a href="http://windowscommunication.net/ControlGallery/ControlDetail.aspx?Control=2278&amp;tabindex=2">static
WorkflowInvoker class</a>, which does all the heavy liting for you, if you want to
host your workflow inside the WCF service method (WCF)</li>
        </ol>
        <p>
I'm going to focus on Ad 1 and Ad 2 in this post.
</p>
        <p>
          <strong>Ad 1:</strong>
        </p>
        <p>
There's an option to host your workflow library inside a web service by using a "Publish
as a Web Service" option inside Visual Studio 2005. This creates a separate ASP .NET
Web Service project inside your current solution, which you can later manually or
automatically publish as a web site to your IIS of choice.
</p>
        <p>
The are <em>two major downsides</em> to this story. The first is that this gives
you practically no control over how the web service is created. Second downside,
while documented, is that the current implementation of <font face="Courier New">System.Workflow.Runtime.WorkflowWebHostingModule</font> works
in particular ways with the workflow persistence story.
</p>
        <p>
Let's assume we have to following interface defined for this web service:
</p>
        <p>
          <font face="Courier New">interface <strong>IServiceInterface<br /></strong></font>
          <font face="Courier New">{<br /></font>
          <font face="Courier New">   void <strong>SendOrder</strong>(Order
order);<br /></font>
          <font face="Courier New">   Order <strong>GetOrder</strong>(Guid
guidOrder);<br /></font>
          <font face="Courier New">   int <strong>GetOrderStatus</strong>(Guid
guidOrder);<br /></font>
          <font face="Courier New">}</font>
        </p>
        <p>
What happens is (request number 1):
</p>
        <ol>
          <li>
You publish your workflow as a web service 
</li>
          <li>
You hit the service endpoint with a browser 
</li>
          <li>
Workflow instance gets created, is run and returns a result 
</li>
          <li>
At this time the workflow runtime (System.Workflow.Runtime.WorkflowRuntime instance)
creates a workflow instance and runs it. Since workflow completes succesfully it destroys
the instance at the end of execution. 
</li>
          <li>
Workflow runtime returns a cookie with the workflow instance back to the browser and
since IE's default setting is to accept cookies, it is written to the client's disk</li>
        </ol>
        <p>
All good, right?
</p>
        <p>
Actually, what happens during request number 2?
</p>
        <ol>
          <li>
You hit the endpoint <strong>again</strong></li>
          <li>
IE knows that the site has a persisted cookie, so it sends it bundled with the SOAP
request 
</li>
          <li>
Workflow runtime sees it and tries to load the specified workflow instance 
</li>
          <li>
This instance is long gone, it does not exist in memory (it has been destroyed, remember?),
so workflow runtime tries to rehydrate it from a persistence store. If there is a
persistence store defined it goes there (most probably <font face="Courier New">WorkflowPersistenceStore</font> in
SQL Server) and correctly identifies that the workflow instance is not present, so
it <strong>fails</strong> with <font face="Courier New">'Workflow with id &lt;GUID&gt;
not found in state persistence store.'</font>. If the persistence store is not
defined for this workflow it <strong>fails</strong> with <font face="Courier New">'The
workflow hosting environment does not have a persistence service as required by an
operation on the workflow instance &lt;GUID&gt;.'</font>.</li>
        </ol>
        <p>
And all this is actually the expected behavior if you think hard enough. Workaround?
Hit the endpoint with a newly loaded IE window. It works every time, since a
cookie with an instance ID is not present.
</p>
        <p>
Another thing to mention here is that this issue does not manifest itself if you hit
the endpoint programatically using the web service proxy, unless you are using a <font face="Courier New">CookieContainer</font> class
to cache the returning cookies.
</p>
        <p>
          <strong>Ad 2:</strong>
        </p>
        <p>
Hosting a Windows Workflow manually is another option, which gives you more flexibility
towards the service detail tweeking.
</p>
        <p>
You can host it using the following code:
</p>
        <p>
          <font face="Courier New">[WebService(Namespace = "</font>
          <font face="Courier New">http://webservices.gama-system.com/</font>
          <font face="Courier New">")]<br />
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<br />
public class WorkflowService : System.Web.Services.WebService<br />
{<br />
    // workflow runtime<br />
    <strong>private static WorkflowRuntime workflowRuntime = new WorkflowRuntime();</strong><br />
    <br /></font>
          <font face="Courier New">    [WebMethod]<br />
    public void SendOrder(Order order)<br />
    {<br /></font>
          <font face="Courier New">        AutoResetEvent
waitHandle = new AutoResetEvent(false);<br />
        workflowRuntime.WorkflowCompleted +=<br />
           delegate(object sender,
WorkflowCompletedEventArgs e)<br />
        {<br />
            waitHandle.Set();<br />
        };<br />
        
<br />
        workflowRuntime.WorkflowTerminated +=<br />
           delegate(object sender,
WorkflowTerminatedEventArgs e)<br />
        {<br />
            waitHandle.Set();<br />
        };</font>
        </p>
        <p>
          <font face="Courier New">        // create workflow
instance with the specified parameters<br />
        WorkflowInstance instance =<br />
           workflowRuntime.CreateWorkflow(typeof(MyWorkflow));<br />
        instance.Start();</font>
        </p>
        <p>
          <font face="Courier New">        waitHandle.WaitOne();<br />
    }    
<br />
}</font>
        </p>
        <p>
An important thing in the specified sample is that the <font face="Courier New">System.Workflow.Runtime.WorkflowRuntime</font> instance
is static to the service implementation class. This is a requirement, since the workflow
runtime can only get loaded once per appdomain. If this is not the case you will get
an exception during the second invocation of the workflow.
</p>
        <p>
If you are using any additional workflow runtime services, like persistence, tracking
or your own communication service to communicate with the workflow you will need to
track that the services get loaded once only. Here's the example:
</p>
        <p>
          <font face="Courier New">[WebService(Namespace = "</font>
          <font face="Courier New">http://webservices.gama-system.com/</font>
          <font face="Courier New">")]<br />
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<br />
public class WorkflowService : System.Web.Services.WebService<br />
{<br />
    // workflow runtime<br />
    <strong>private static WorkflowRuntime workflowRuntime = new WorkflowRuntime();</strong><br />
    
<br />
    </font>
          <font face="Courier New">// services added<br />
    <strong>private static bool booServicesAdded = false;</strong></font>
        </p>
        <p>
          <font face="Courier New">    // communication service<br />
    <strong>private static CommunicationService objComm = new CommunicationService();<br /></strong><br /></font>
          <font face="Courier New">    [WebMethod]<br />
    public void SendOrder(Order order)<br />
    {<br /></font>
          <font face="Courier New">        <strong>//
add communication service<br />
        if (!booServicesAdded)<br />
        {<br />
            ExternalDataExchangeService
externalService =<br />
              
new ExternalDataExchangeService();<br />
            workflowRuntime.AddService(externalService);<br />
            externalService.AddService(objComm);<br />
            booServiceAdded
= true;<br />
        }<br /></strong><br /></font>
          <font face="Courier New">        AutoResetEvent
waitHandle = new AutoResetEvent(false);<br />
        workflowRuntime.WorkflowCompleted +=<br />
           delegate(object sender,
WorkflowCompletedEventArgs e)<br />
        {<br />
            waitHandle.Set();<br />
        };<br />
        
<br />
        workflowRuntime.WorkflowTerminated +=<br />
           delegate(object sender,
WorkflowTerminatedEventArgs e)<br />
        {<br />
            waitHandle.Set();<br />
        };</font>
        </p>
        <p>
          <font face="Courier New">        // create workflow
instance with the specified parameters<br />
        WorkflowInstance instance =<br />
           workflowRuntime.CreateWorkflow(typeof(MyWorkflow));<br />
        instance.Start();</font>
        </p>
        <p>
          <font face="Courier New">        waitHandle.WaitOne();<br />
    }    
<br />
}</font>
        </p>
        <p>
This adds the required services only during the first invocation of a web service.
Since workflow runtime is a static class the services get persisted during all subsequent
service calls. A boolean variable <font face="Courier New">booServicesAdded</font> is
responsible for flag storage.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=21c95c2c-63d7-44f6-8357-1be0ecb6f264" />
      </body>
      <title>Windows Workflow Foundation: Exposing Workflows as Services</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,21c95c2c-63d7-44f6-8357-1be0ecb6f264.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,21c95c2c-63d7-44f6-8357-1be0ecb6f264.aspx</link>
      <pubDate>Wed, 10 May 2006 08:55:37 GMT</pubDate>
      <description>&lt;p&gt;
There are currently a couple of options to expose a Windows Workflow as as service.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
There is a native option to publish a developed Workflow Library project as a ASP
.NET Web Service (ASMX). 
&lt;li&gt;
You can host it yourself (ASMX, WCF) 
&lt;li&gt;
&lt;a href="http://www.softwaremaker.net/blog/"&gt;William Tay&lt;/a&gt; is doing excellent work
towards &lt;a href="http://www.softwaremaker.net/blog/HookingAWorkflowIntoYourWCFDispatcher.aspx"&gt;hosting
a workflow inside the WCF service pipeline&lt;/a&gt;&amp;nbsp;(WCF) 
&lt;li&gt;
&lt;a href="http://www.codeproject.com/script/profile/whos_who.asp?vt=arts&amp;amp;id=24570"&gt;Roman
Kiss&lt;/a&gt; created a &lt;a href="http://windowscommunication.net/ControlGallery/ControlDetail.aspx?Control=2278&amp;amp;tabindex=2"&gt;static
WorkflowInvoker class&lt;/a&gt;, which does all the heavy liting for you, if you want to
host your workflow inside the WCF service method (WCF)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
I'm going to focus on Ad 1 and Ad 2 in this post.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Ad 1:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
There's an option to host your workflow library inside a web service by using a "Publish
as a Web Service" option inside Visual Studio 2005. This creates a separate ASP .NET
Web Service project inside your current solution, which you can later manually or
automatically publish as a web site to your IIS of choice.
&lt;/p&gt;
&lt;p&gt;
The are &lt;em&gt;two major downsides&lt;/em&gt; to this story. The first is&amp;nbsp;that this gives
you practically no control over how&amp;nbsp;the web service is created. Second downside,
while documented, is that the current implementation of &lt;font face="Courier New"&gt;System.Workflow.Runtime.WorkflowWebHostingModule&lt;/font&gt; works
in particular ways with the workflow persistence story.
&lt;/p&gt;
&lt;p&gt;
Let's assume we have to following interface defined for this web service:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;interface &lt;strong&gt;IServiceInterface&lt;br&gt;
&lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;{&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;void &lt;strong&gt;SendOrder&lt;/strong&gt;(Order
order);&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Order &lt;strong&gt;GetOrder&lt;/strong&gt;(Guid
guidOrder);&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;int &lt;strong&gt;GetOrderStatus&lt;/strong&gt;(Guid
guidOrder);&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
What happens is (request number 1):
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
You publish your workflow as a web service 
&lt;li&gt;
You hit the service endpoint with a browser 
&lt;li&gt;
Workflow instance gets created, is run and returns a result 
&lt;li&gt;
At this time the workflow runtime (System.Workflow.Runtime.WorkflowRuntime instance)
creates a workflow instance and runs it. Since workflow completes succesfully it destroys
the instance at the end of execution. 
&lt;li&gt;
Workflow runtime returns a cookie with the workflow instance back to the browser and
since IE's default setting is to accept cookies, it is written to the client's disk&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
All good, right?
&lt;/p&gt;
&lt;p&gt;
Actually, what happens&amp;nbsp;during request number 2?
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
You hit the endpoint &lt;strong&gt;again&lt;/strong&gt; 
&lt;li&gt;
IE knows that the site has a persisted cookie, so it sends it bundled with the SOAP
request 
&lt;li&gt;
Workflow runtime sees it and tries to load the specified workflow instance 
&lt;li&gt;
This instance is long gone, it does not exist in memory (it has been destroyed, remember?),
so workflow runtime tries to rehydrate it from a persistence store. If there is a
persistence store defined it goes there (most probably &lt;font face="Courier New"&gt;WorkflowPersistenceStore&lt;/font&gt; in
SQL Server) and correctly identifies that the workflow instance is not present, so
it &lt;strong&gt;fails&lt;/strong&gt; with &lt;font face="Courier New"&gt;'Workflow with id&amp;nbsp;&amp;lt;GUID&amp;gt;
not found in state persistence store.'&lt;/font&gt;.&amp;nbsp;If the persistence store is not
defined for this workflow it &lt;strong&gt;fails&lt;/strong&gt; with &lt;font face="Courier New"&gt;'The
workflow hosting environment does not have a persistence service as required by an
operation on the workflow instance &amp;lt;GUID&amp;gt;.'&lt;/font&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
And all this is actually the expected behavior if you think hard enough. Workaround?
Hit the endpoint with a newly loaded&amp;nbsp;IE window. It works every time, since a
cookie with an instance ID is not present.
&lt;/p&gt;
&lt;p&gt;
Another thing to mention here is that this issue does not manifest itself if you hit
the endpoint programatically using the web service proxy, unless you are using a &lt;font face="Courier New"&gt;CookieContainer&lt;/font&gt; class
to cache the returning cookies.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Ad 2:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Hosting a Windows Workflow manually is another option, which gives you more flexibility
towards the service detail tweeking.
&lt;/p&gt;
&lt;p&gt;
You can host it using the following code:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[WebService(Namespace = "&lt;/font&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/&lt;/font&gt;&lt;font face="Courier New"&gt;")]&lt;br&gt;
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]&lt;br&gt;
public class&amp;nbsp;WorkflowService : System.Web.Services.WebService&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // workflow runtime&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;private static WorkflowRuntime workflowRuntime = new WorkflowRuntime();&lt;/strong&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [WebMethod]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&amp;nbsp;void SendOrder(Order order)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AutoResetEvent
waitHandle = new AutoResetEvent(false);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workflowRuntime.WorkflowCompleted +=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delegate(object sender,
WorkflowCompletedEventArgs e)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; waitHandle.Set();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workflowRuntime.WorkflowTerminated +=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delegate(object sender,
WorkflowTerminatedEventArgs e)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; waitHandle.Set();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // create workflow
instance with the specified parameters&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WorkflowInstance instance =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workflowRuntime.CreateWorkflow(typeof(MyWorkflow));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instance.Start();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; waitHandle.WaitOne();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
An important thing in the specified sample is that the &lt;font face="Courier New"&gt;System.Workflow.Runtime.WorkflowRuntime&lt;/font&gt; instance
is static to the service implementation class. This is a requirement, since the workflow
runtime can only get loaded once per appdomain. If this is not the case you will get
an exception during the second invocation of the workflow.
&lt;/p&gt;
&lt;p&gt;
If you are using any additional workflow runtime services, like persistence, tracking
or your own communication service to communicate with the workflow you will need to
track that the services get loaded once only. Here's the example:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[WebService(Namespace = "&lt;/font&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/&lt;/font&gt;&lt;font face="Courier New"&gt;")]&lt;br&gt;
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]&lt;br&gt;
public class&amp;nbsp;WorkflowService : System.Web.Services.WebService&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // workflow runtime&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;private static WorkflowRuntime workflowRuntime = new WorkflowRuntime();&lt;/strong&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font face="Courier New"&gt;// services added&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;private static bool booServicesAdded = false;&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // communication&amp;nbsp;service&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;private static CommunicationService objComm = new CommunicationService();&lt;br&gt;
&lt;/strong&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [WebMethod]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&amp;nbsp;void SendOrder(Order order)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;//
add communication service&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!booServicesAdded)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ExternalDataExchangeService
externalService =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
new ExternalDataExchangeService();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workflowRuntime.AddService(externalService);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; externalService.AddService(objComm);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; booServiceAdded
= true;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/strong&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AutoResetEvent
waitHandle = new AutoResetEvent(false);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workflowRuntime.WorkflowCompleted +=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delegate(object sender,
WorkflowCompletedEventArgs e)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; waitHandle.Set();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workflowRuntime.WorkflowTerminated +=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delegate(object sender,
WorkflowTerminatedEventArgs e)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; waitHandle.Set();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // create workflow
instance with the specified parameters&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WorkflowInstance instance =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workflowRuntime.CreateWorkflow(typeof(MyWorkflow));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instance.Start();&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; waitHandle.WaitOne();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This adds the required services only during the first invocation of a web service.
Since workflow runtime is a static class the services get persisted during all subsequent
service calls. A boolean variable &lt;font face="Courier New"&gt;booServicesAdded&lt;/font&gt; is
responsible for flag storage.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=21c95c2c-63d7-44f6-8357-1be0ecb6f264" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,21c95c2c-63d7-44f6-8357-1be0ecb6f264.aspx</comments>
      <category>Web Services</category>
      <category>.NET 3.0 - WCF</category>
      <category>.NET 3.0 - WF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=e9bb929b-d0b4-4626-b302-1d2715fc344a</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,e9bb929b-d0b4-4626-b302-1d2715fc344a.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,e9bb929b-d0b4-4626-b302-1d2715fc344a.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=e9bb929b-d0b4-4626-b302-1d2715fc344a</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Having spent a lot of time reasoning about <a href="http://msdn.microsoft.com/webservices/indigo/default.aspx">WCF</a> and
certificate based authentication, here's a scoop.
</p>
        <p>
This forces WCF to expect a client side certificate for message based security:
</p>
        <p>
          <font face="Courier New">&lt;behavior name="DefaultBehavior" returnUnknownExceptionsAsFaults="false"
&gt;<br />
  &lt;serviceCredentials&gt;<br />
    &lt;serviceCertificate<br />
      x509FindType="FindBySubjectName"<br />
      findValue="MyCertificate"<br />
      storeLocation="LocalMachine"<br />
      storeName="My"/&gt;<br />
    &lt;clientCertificate&gt;<br />
      &lt;authentication <font color="#0000ff">certificateValidationMode="ChainTrust"
revocationMode="Online"</font>/&gt;<br />
    &lt;/clientCertificate&gt;<br />
  &lt;/serviceCredentials&gt;<br />
  &lt;metadataPublishing enableGetWsdl="true" enableMetadataExchange="true" enableHelpPage="true"/&gt;<br />
&lt;/behavior&gt;</font>
        </p>
        <p>
What it says is that the client certificate must validate according to the complete
certificate chain. In broader terms it forces the caller to use the certificate that
is 'validatable' on the service side. This means the following:
</p>
        <ol>
          <li>
The certificate must be present at the time of request generation (client side)</li>
          <li>
The certificate must be valid according to expiration period and certificate
generation (checking done on server side)</li>
          <li>
The certificate chain (issuing CAs path) must be valid (<font face="Courier New">certificateValidationMode="ChainTrust"</font>)</li>
          <li>
The certificate must not be obsolete and/or revoked (<font face="Courier New">revocationMode="Online"</font>)</li>
        </ol>
        <p>
Other authentication options of <font face="Courier New">certificateValidationMode</font> and <font face="Courier New">revocationMode</font> include:
</p>
        <ul>
          <li>
            <font face="Courier New">certificateValidationMode</font> can take a velue of <font face="Courier New">ChainTrust</font>, <font face="Courier New">PeerTrust</font>, <font face="Courier New">ChainOrPeerTrust</font>, <font face="Courier New">None</font> or <font face="Courier New">Custom. </font><font face="Courier New">None</font> means
that no certificate checking is done, <font face="Courier New">Custom</font> allows
one to plug in a custom <font face="Courier New">X509CertificateValidator</font> (new, <font face="Courier New">System.IdentityModel.Selectors</font> namespace), <font face="Courier New">PeerTrust</font> forces
a public key of the client certificate to be present in the 'Trusted People' certificate
store on the service side and <font face="Courier New">ChainTrust</font> requests
that the client cert can be validated against the root certificates on the server
side. <font face="Courier New">ChainOrPeerTrust</font> just executes the OR operator
on the last two.<br /><em>Remark:</em><font face="Courier New">PeerTrust</font> and <font face="Courier New">ChainOrPeerTrust</font> are
also subjected to another attribute called <font face="Courier New">trustedStoreLocation</font>.
If peer trust is demanded, one can specify where the public keys are present, meaning
either in <font face="Courier New">LocalMachine</font> or <font face="Courier New">CurrentUser</font> store.<br /></li>
          <li>
            <font face="Courier New">revocationMode</font> takes the following value list: <font face="Courier New">None</font>, <font face="Courier New">Online</font> or <font face="Courier New">Cached</font>. <font face="Courier New">None</font> is
saying that CRL (Certificate Revocation List) is not checked. <font face="Courier New">Online</font> demands
that service checks (at every request) whether the certificate is still valid and
thus not revoked. <font face="Courier New">Offline</font> says that the certificate
should only be checked against the cached CRL.<br /><em>Remark:</em><font face="Courier New">Online</font> does not mean that CRL will
be downloaded from the CA CRL endpoint at every request. It means it will check a
local copy of it at every request. Every CRL has a validity period, when it expires,
it is downloaded again.</li>
        </ul>
        <p>
The <font face="Courier New">&lt;metadataPublishing&gt;</font> element is there just
to allow WSDL/MetadataExchange endpoints to exist. It also allows the familiar service
HTML page to pop up if you hit the endpoint (courtesy of <font face="Courier New">enableHelpPage="true"</font>).
</p>
        <p>
          <em>Another remark:</em>
          <a href="http://msdn.microsoft.com/windowsvista/downloads/getthebeta/default.aspx">Current</a> February
2006 WCF CTP bits do not reflect the naming used in this post. For example <font face="Courier New">revocationMode="Cached"</font> was
renamed from <font face="Courier New">revocationMode=Offline"</font>, but don't be
afraid of using it, nevertheless.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=e9bb929b-d0b4-4626-b302-1d2715fc344a" />
      </body>
      <title>WCF: certificateValidationMode and revocationMode</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,e9bb929b-d0b4-4626-b302-1d2715fc344a.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,e9bb929b-d0b4-4626-b302-1d2715fc344a.aspx</link>
      <pubDate>Thu, 27 Apr 2006 19:33:59 GMT</pubDate>
      <description>&lt;p&gt;
Having spent a lot of time reasoning about &lt;a href="http://msdn.microsoft.com/webservices/indigo/default.aspx"&gt;WCF&lt;/a&gt; and
certificate based authentication, here's a scoop.
&lt;/p&gt;
&lt;p&gt;
This forces WCF to expect a client side certificate for&amp;nbsp;message based&amp;nbsp;security:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;behavior name="DefaultBehavior" returnUnknownExceptionsAsFaults="false"
&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;serviceCredentials&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceCertificate&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x509FindType="FindBySubjectName"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; findValue="MyCertificate"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; storeLocation="LocalMachine"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; storeName="My"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;clientCertificate&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;authentication &lt;font color=#0000ff&gt;certificateValidationMode="ChainTrust"
revocationMode="Online"&lt;/font&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/clientCertificate&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/serviceCredentials&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;metadataPublishing enableGetWsdl="true" enableMetadataExchange="true" enableHelpPage="true"/&amp;gt;&lt;br&gt;
&amp;lt;/behavior&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
What it says is that the client certificate must validate according to the complete
certificate chain. In broader terms it forces the caller to use the certificate that
is 'validatable' on the service side. This means the following:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
The certificate must be present at the time of request generation (client side)&lt;/li&gt;
&lt;li&gt;
The certificate must be valid according to expiration period and&amp;nbsp;certificate
generation (checking done&amp;nbsp;on&amp;nbsp;server side)&lt;/li&gt;
&lt;li&gt;
The certificate chain (issuing CAs path) must be valid (&lt;font face="Courier New"&gt;certificateValidationMode="ChainTrust"&lt;/font&gt;)&lt;/li&gt;
&lt;li&gt;
The certificate must not be obsolete and/or revoked&amp;nbsp;(&lt;font face="Courier New"&gt;revocationMode="Online"&lt;/font&gt;)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Other authentication options of &lt;font face="Courier New"&gt;certificateValidationMode&lt;/font&gt; and &lt;font face="Courier New"&gt;revocationMode&lt;/font&gt; include:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;certificateValidationMode&lt;/font&gt; can take a velue of &lt;font face="Courier New"&gt;ChainTrust&lt;/font&gt;, &lt;font face="Courier New"&gt;PeerTrust&lt;/font&gt;, &lt;font face="Courier New"&gt;ChainOrPeerTrust&lt;/font&gt;, &lt;font face="Courier New"&gt;None&lt;/font&gt; or&amp;nbsp;&lt;font face="Courier New"&gt;Custom. &lt;/font&gt;&lt;font face="Courier New"&gt;None&lt;/font&gt; means
that no certificate checking is done, &lt;font face="Courier New"&gt;Custom&lt;/font&gt; allows
one to plug in a custom &lt;font face="Courier New"&gt;X509CertificateValidator&lt;/font&gt; (new, &lt;font face="Courier New"&gt;System.IdentityModel.Selectors&lt;/font&gt; namespace), &lt;font face="Courier New"&gt;PeerTrust&lt;/font&gt; forces
a public key of the client certificate to be present in the 'Trusted People' certificate
store on the service side and&amp;nbsp;&lt;font face="Courier New"&gt;ChainTrust&lt;/font&gt; requests
that the client cert can be validated against the root certificates on the server
side. &lt;font face="Courier New"&gt;ChainOrPeerTrust&lt;/font&gt; just executes the OR operator
on the last two.&lt;br&gt;
&lt;em&gt;Remark:&lt;/em&gt; &lt;font face="Courier New"&gt;PeerTrust&lt;/font&gt; and &lt;font face="Courier New"&gt;ChainOrPeerTrust&lt;/font&gt; are
also subjected to another attribute called &lt;font face="Courier New"&gt;trustedStoreLocation&lt;/font&gt;.
If peer trust is demanded, one can specify where the public keys are present, meaning
either in &lt;font face="Courier New"&gt;LocalMachine&lt;/font&gt; or &lt;font face="Courier New"&gt;CurrentUser&lt;/font&gt; store.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;revocationMode&lt;/font&gt; takes the following value list: &lt;font face="Courier New"&gt;None&lt;/font&gt;, &lt;font face="Courier New"&gt;Online&lt;/font&gt; or &lt;font face="Courier New"&gt;Cached&lt;/font&gt;. &lt;font face="Courier New"&gt;None&lt;/font&gt; is
saying that CRL (Certificate Revocation List) is not checked. &lt;font face="Courier New"&gt;Online&lt;/font&gt; demands
that service checks (at every request) whether the certificate is still valid and
thus not revoked. &lt;font face="Courier New"&gt;Offline&lt;/font&gt; says that the certificate
should only be checked against the cached CRL.&lt;br&gt;
&lt;em&gt;Remark:&lt;/em&gt; &lt;font face="Courier New"&gt;Online&lt;/font&gt; does not mean that CRL will
be downloaded from the CA CRL endpoint at every request. It means it will check a
local copy of it at every request. Every CRL has a validity period, when it expires,
it is downloaded again.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The &lt;font face="Courier New"&gt;&amp;lt;metadataPublishing&amp;gt;&lt;/font&gt; element is there just
to allow WSDL/MetadataExchange endpoints to exist. It also allows the familiar service
HTML page to pop up if you hit the endpoint (courtesy of &lt;font face="Courier New"&gt;enableHelpPage="true"&lt;/font&gt;).
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Another remark:&lt;/em&gt; &lt;a href="http://msdn.microsoft.com/windowsvista/downloads/getthebeta/default.aspx"&gt;Current&lt;/a&gt; February
2006 WCF CTP bits do not reflect the naming used in this post. For example &lt;font face="Courier New"&gt;revocationMode="Cached"&lt;/font&gt; was
renamed from &lt;font face="Courier New"&gt;revocationMode=Offline"&lt;/font&gt;, but don't be
afraid of using it, nevertheless.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=e9bb929b-d0b4-4626-b302-1d2715fc344a" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,e9bb929b-d0b4-4626-b302-1d2715fc344a.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=826aa47b-b68d-4044-8d15-892e6f89f19e</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,826aa47b-b68d-4044-8d15-892e6f89f19e.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,826aa47b-b68d-4044-8d15-892e6f89f19e.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=826aa47b-b68d-4044-8d15-892e6f89f19e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Juval Lowy, a fellow RD, posted a complete and compatibile Visual Studio 2005 schema
for February 2006 CTP of Indigo (WCF).
</p>
        <p>
Download <a href="http://www.idesign.net/idesign/temp/dotNetConfig.zip">here</a>.
</p>
        <p>
Copy it to Visual Studio Schema directory: <font face="Courier New">c:\program files\microsoft
visual studio 8\xml\schemas</font>.
</p>
        <p>
I wonder how he did it.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=826aa47b-b68d-4044-8d15-892e6f89f19e" />
      </body>
      <title>WCF February 2006 Intellisense Schema</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,826aa47b-b68d-4044-8d15-892e6f89f19e.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,826aa47b-b68d-4044-8d15-892e6f89f19e.aspx</link>
      <pubDate>Wed, 08 Mar 2006 18:05:05 GMT</pubDate>
      <description>&lt;p&gt;
Juval Lowy, a fellow RD, posted a complete and compatibile Visual Studio 2005 schema
for February 2006 CTP of Indigo (WCF).
&lt;/p&gt;
&lt;p&gt;
Download &lt;a href="http://www.idesign.net/idesign/temp/dotNetConfig.zip"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Copy it to Visual Studio Schema directory: &lt;font face="Courier New"&gt;c:\program files\microsoft
visual studio 8\xml\schemas&lt;/font&gt;.
&lt;/p&gt;
&lt;p&gt;
I wonder how he did it.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=826aa47b-b68d-4044-8d15-892e6f89f19e" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,826aa47b-b68d-4044-8d15-892e6f89f19e.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=ffdb26c2-2028-4bfa-b565-db59fe1da4d4</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,ffdb26c2-2028-4bfa-b565-db59fe1da4d4.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,ffdb26c2-2028-4bfa-b565-db59fe1da4d4.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=ffdb26c2-2028-4bfa-b565-db59fe1da4d4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here you can find today's source code I did on SLODUG (Slovenian Developers User Group):
</p>
        <p>
          <a href="http://www.request-response.com/blog/content/binary/SLODUG_Feb2006_WCF.zip">SLODUG_Feb2006_WCF.zip
(39,67 KB)</a>
        </p>
        <p>
It's an Indigo service with a corresponding client. It uses three different endpoints
with separate transport semantics.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=ffdb26c2-2028-4bfa-b565-db59fe1da4d4" />
      </body>
      <title>SLODUG February 2006</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,ffdb26c2-2028-4bfa-b565-db59fe1da4d4.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,ffdb26c2-2028-4bfa-b565-db59fe1da4d4.aspx</link>
      <pubDate>Wed, 15 Feb 2006 21:47:40 GMT</pubDate>
      <description>&lt;p&gt;
Here you can find today's source code I did on SLODUG (Slovenian Developers User Group):
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.request-response.com/blog/content/binary/SLODUG_Feb2006_WCF.zip"&gt;SLODUG_Feb2006_WCF.zip
(39,67 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
It's an Indigo service with a corresponding client. It uses three different endpoints
with separate transport semantics.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=ffdb26c2-2028-4bfa-b565-db59fe1da4d4" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,ffdb26c2-2028-4bfa-b565-db59fe1da4d4.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=9b13af92-743c-41da-bfab-e90410b27650</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,9b13af92-743c-41da-bfab-e90410b27650.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,9b13af92-743c-41da-bfab-e90410b27650.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9b13af92-743c-41da-bfab-e90410b27650</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The following is a list of Windows Communication Foundation (read Indigo) changes
from September CTP (beta 1) to November CTP (beta 2 RC0).
</p>
        <p>
Most of them are name changes. Nevertheless, you will need to update at least configuration,
since element/attribute naming there has changed quite a lot.
</p>
        <p>
Class name changes:
</p>
        <ol>
          <li>
            <font face="Courier New">Fault&lt;T&gt;       FaultException&lt;T&gt;</font>
          </li>
          <li>
            <font face="Courier New">UnknownFault   UnknownFaultException</font>
          </li>
          <li>
            <font face="Courier New">ServiceSite    InstanceContext</font>
          </li>
        </ol>
        <p>
Parameters of [OperationBehaviour] attribute:
</p>
        <ol>
          <li>
            <font face="Courier New">AutoCompleteTransaction TransactionAutoComplete</font>
          </li>
          <li>
            <font face="Courier New">AutoEnlistTransaction   TransactionScopeRequired</font>
          </li>
        </ol>
        <p>
Other changes:
</p>
        <ol>
          <li>
            <font face="Courier New">ServiceHost&lt;T&gt;   ServiceHost(typeof(T)&gt;</font>
          </li>
        </ol>
        <p>
Binding names:
</p>
        <ol>
          <li>
            <font face="Courier New">wsProfileBinding           
wsHttpBinding</font>
          </li>
          <li>
            <font face="Courier New">netProfileTcpBinding       
netTcpBinding</font>
          </li>
          <li>
            <font face="Courier New">netProfileDualTcpBinding    netTcpBinding</font>
          </li>
          <li>
            <font face="Courier New">netProfileNamedPipeBinding  netNamedPipeBinding</font>
          </li>
          <li>
            <font face="Courier New">basicProfileBinding        
basicHttpBinding</font>
          </li>
        </ol>
        <p>
Configuration element/attribute name changes:
</p>
        <ol>
          <li>
            <font face="Courier New">/services/service[@serviceType]                  
/services/service[@type]</font>
          </li>
          <li>
            <font face="Courier New">/endpoints/endpoint[@contractType]               
/endpoints/endpoint[@contact]</font>
          </li>
          <li>
            <font face="Courier New">/services/service/endpoint[@bindingSectionName]   /services/service/endpoint[@binding]</font>
          </li>
          <li>
            <font face="Courier New">/behaviors/behavior[@configurationName]          
/behaviors/behavior[@name]</font>
          </li>
          <li>
            <font face="Courier New">/bindings/*/binding[@configurationName]          
/bindings/*/binding[@name]</font>
          </li>
        </ol>
        <p>
Attribute changes:
</p>
        <ol>
          <li>
            <font face="Courier New">[BindingRequirements(TransactionFlowRequirements=RequirementsMode.Require)]<br />
[TransactionFlow(TransactionFlowOption.Required)] </font>
          </li>
          <li>
            <font face="Courier New">[BindingRequirements(QueuedDeliveryRequirements=RequirementsMode.Require)<br />
[BindingRequirements(QueuedDeliveryRequirements=BindingRequirementsMode.Required)</font>
          </li>
          <li>
            <font face="Courier New">[InstanceMode=InstanceMode.Singleton]<br />
[InstanceContextMode=InstanceContextMode.Single]</font>
          </li>
          <li>
            <font face="Courier New">[InstanceMode=InstanceMode.PrivateSession]<br />
[InstanceContextMode=InstanceContextMode.PerSession]</font>
          </li>
          <li>
            <font face="Courier New">[InstanceMode=InstanceMode.PerCall]<br />
[InstanceContextMode=InstanceContextMode.PerCall]</font>
          </li>
          <li>
            <font face="Courier New">[InstanceMode=InstanceMode.SharedSession]<br />
[InstanceContextMode=InstanceContextMode.Shared]</font>
          </li>
        </ol>
        <p>
This list may not be complete.
</p>
        <p>
I do expect that <font face="Courier New">QueuedDeliveryRequirements</font> property
of <font face="Courier New">[BindingRequirements]</font> attribute will be standalone
when Indigo ships. There's no point in having a separate attribute for expected transaction
semantics and leave out the queued delivery. It's the same concept being pushed down
to administrators (binding requirements are fixed requirements which are supposed
to be met by the admin - they are the developers' law of expected processing model).
</p>
        <p>
Maybe this attribute should be named <font face="Courier New">[QueuedDelivery]</font>,
with appropriate property for demanding it (like <font face="Courier New">QueuedDeliveryOption</font>)
and a property called <font face="Courier New">OrderedSessionOption</font>, which
would handle ordered session maintenance.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=9b13af92-743c-41da-bfab-e90410b27650" />
      </body>
      <title>WCF - List of Changes from Beta 1 to Beta 2 RC0</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,9b13af92-743c-41da-bfab-e90410b27650.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,9b13af92-743c-41da-bfab-e90410b27650.aspx</link>
      <pubDate>Sun, 11 Dec 2005 19:12:52 GMT</pubDate>
      <description>&lt;p&gt;
The following is a list of Windows Communication Foundation (read Indigo) changes
from September CTP (beta 1)&amp;nbsp;to November CTP (beta 2 RC0).
&lt;/p&gt;
&lt;p&gt;
Most of them are name changes. Nevertheless, you will need to update at least configuration,
since element/attribute naming there has changed quite a lot.
&lt;/p&gt;
&lt;p&gt;
Class name changes:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;Fault&amp;lt;T&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FaultException&amp;lt;T&amp;gt;&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;UnknownFault&amp;nbsp;&amp;nbsp;&amp;nbsp;UnknownFaultException&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;ServiceSite&amp;nbsp;&amp;nbsp;&amp;nbsp; InstanceContext&lt;/font&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Parameters of [OperationBehaviour] attribute:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;AutoCompleteTransaction TransactionAutoComplete&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;AutoEnlistTransaction&amp;nbsp;&amp;nbsp;&amp;nbsp;TransactionScopeRequired&lt;/font&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Other changes:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;ServiceHost&amp;lt;T&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ServiceHost(typeof(T)&amp;gt;&lt;/font&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Binding names:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;wsProfileBinding&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
wsHttpBinding&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;netProfileTcpBinding&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
netTcpBinding&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;netProfileDualTcpBinding&amp;nbsp;&amp;nbsp;&amp;nbsp; netTcpBinding&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;netProfileNamedPipeBinding&amp;nbsp; netNamedPipeBinding&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;basicProfileBinding&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
basicHttpBinding&lt;/font&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Configuration element/attribute name changes:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;/services/service[@serviceType]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
/services/service[@type]&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;/endpoints/endpoint[@contractType]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
/endpoints/endpoint[@contact]&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;/services/service/endpoint[@bindingSectionName]&amp;nbsp;&amp;nbsp;&amp;nbsp;/services/service/endpoint[@binding]&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;/behaviors/behavior[@configurationName]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
/behaviors/behavior[@name]&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;/bindings/*/binding[@configurationName]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
/bindings/*/binding[@name]&lt;/font&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Attribute changes:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;[BindingRequirements(TransactionFlowRequirements=RequirementsMode.Require)]&lt;br&gt;
[TransactionFlow(TransactionFlowOption.Required)]&amp;nbsp;&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;[BindingRequirements(QueuedDeliveryRequirements=RequirementsMode.Require)&lt;br&gt;
[BindingRequirements(QueuedDeliveryRequirements=BindingRequirementsMode.Required)&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;[InstanceMode=InstanceMode.Singleton]&lt;br&gt;
[InstanceContextMode=InstanceContextMode.Single]&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;[InstanceMode=InstanceMode.PrivateSession]&lt;br&gt;
[InstanceContextMode=InstanceContextMode.PerSession]&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;[InstanceMode=InstanceMode.PerCall]&lt;br&gt;
[InstanceContextMode=InstanceContextMode.PerCall]&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;[InstanceMode=InstanceMode.SharedSession]&lt;br&gt;
[InstanceContextMode=InstanceContextMode.Shared]&lt;/font&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
This list may not be complete.
&lt;/p&gt;
&lt;p&gt;
I do expect that &lt;font face="Courier New"&gt;QueuedDeliveryRequirements&lt;/font&gt; property
of &lt;font face="Courier New"&gt;[BindingRequirements]&lt;/font&gt; attribute will be standalone
when Indigo ships. There's no point in having a separate attribute for expected transaction
semantics and leave out the queued delivery. It's the same concept being pushed down
to administrators (binding requirements are fixed requirements which are supposed
to be met by the admin - they are the developers' law of expected processing model).
&lt;/p&gt;
&lt;p&gt;
Maybe this attribute should be named &lt;font face="Courier New"&gt;[QueuedDelivery]&lt;/font&gt;,
with appropriate property for demanding it (like &lt;font face="Courier New"&gt;QueuedDeliveryOption&lt;/font&gt;)
and a property called &lt;font face="Courier New"&gt;OrderedSessionOption&lt;/font&gt;, which
would handle ordered session maintenance.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=9b13af92-743c-41da-bfab-e90410b27650" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,9b13af92-743c-41da-bfab-e90410b27650.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>Transactions</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=5371ff94-3412-4e41-87f7-3740c8e04ac4</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,5371ff94-3412-4e41-87f7-3740c8e04ac4.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,5371ff94-3412-4e41-87f7-3740c8e04ac4.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=5371ff94-3412-4e41-87f7-3740c8e04ac4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There is a common functionality request in modern distributed applications that clients
and services (client also being other services) could communicate using different
communication protocols and/or different transport semantics inside a single protocol.
</p>
        <p>
For this sample we're going to limit ourselves to HTTP messaging, but this does not
limit the scope of the article. Other transport protocols can be added without obstructing
other transport mechanisms.
</p>
        <p>
To allow this scenario Indigo (Windows Communication Foundation, WCF) allows multiple
endpoints per service to be setup. Service side bindings can, for example, be the
following:
</p>
        <p>
          <font face="Courier New">&lt;bindings&gt;<br />
  &lt;wsProfileBinding&gt;<br />
    &lt;binding 
<br />
      configurationName="Secure" 
<br />
      orderedSession="false" 
<br />
      reliableSessionEnabled="false" 
<br />
      securityMode="WSSecurityOverHttp" 
<br />
      maxMessageSize="134217728"<br />
      flowTransactions="NotAllowed"<br />
      messageEncoding="Text"&gt;<br />
      &lt;wsSecurity 
<br />
        authenticationMode="Certificate" 
<br />
        useNegotiation="true" /&gt;<br />
    &lt;/binding&gt;<br />
    &lt;binding 
<br />
      configurationName="SecureReliable" 
<br />
      orderedSession="true" 
<br />
      reliableSessionEnabled="true" 
<br />
      securityMode="WSSecurityOverHttp"<br />
      maxMessageSize="134217728"<br />
      flowTransactions="NotAllowed"<br />
      messageEncoding="Text"&gt;<br />
      &lt;wsSecurity<br />
        authenticationMode="Certificate" 
<br />
        useNegotiation="true" /&gt;<br />
    &lt;/binding&gt;<br />
    &lt;binding<br />
      configurationName="SecureReliableTransacted" 
<br />
      orderedSession="true" 
<br />
      reliableSessionEnabled="true" 
<br />
      securityMode="WSSecurityOverHttp"<br />
      maxMessageSize="134217728"<br />
      flowTransactions="Allowed"<br />
      messageEncoding="Text"&gt;<br />
      &lt;wsSecurity 
<br />
        authenticationMode="Certificate" 
<br />
        useNegotiation="true" /&gt;<br />
    &lt;/binding&gt;<br />
    &lt;binding 
<br />
      configurationName="SecureMTOM" 
<br />
      orderedSession="false" 
<br />
      reliableSessionEnabled="false" 
<br />
      securityMode="WSSecurityOverHttp" 
<br />
      maxMessageSize="134217728"<br />
      flowTransactions="NotAllowed"<br />
      messageEncoding="Mtom"&gt;<br />
      &lt;wsSecurity 
<br />
        authenticationMode="Certificate" 
<br />
        useNegotiation="true" /&gt;<br />
    &lt;/binding&gt;<br />
    &lt;binding 
<br />
      configurationName="SecureReliableMTOM" 
<br />
      orderedSession="true" 
<br />
      reliableSessionEnabled="true" 
<br />
      securityMode="WSSecurityOverHttp"<br />
      maxMessageSize="134217728"<br />
      flowTransactions="NotAllowed"<br />
      messageEncoding="Mtom"&gt;<br />
      &lt;wsSecurity 
<br />
        authenticationMode="Certificate" 
<br />
        useNegotiation="true" /&gt;<br />
    &lt;/binding&gt;<br />
   &lt;binding<br />
      configurationName="SecureReliableTransactedMTOM" 
<br />
      orderedSession="true" 
<br />
      reliableSessionEnabled="true" 
<br />
      securityMode="WSSecurityOverHttp"<br />
      maxMessageSize="134217728"<br />
      flowTransactions="Allowed"<br />
      messageEncoding="Mtom"&gt;<br />
      &lt;wsSecurity 
<br />
        authenticationMode="Certificate" 
<br />
        useNegotiation="true" /&gt;<br />
    &lt;/binding&gt;<br />
  &lt;/wsProfileBinding&gt;<br />
&lt;/bindings&gt;</font>
        </p>
        <p>
There are six different bindings setup:
</p>
        <ul>
          <li>
Secure 
</li>
          <li>
SecureReliable 
</li>
          <li>
SecureReliableTransacted 
</li>
          <li>
SecureMTOM 
</li>
          <li>
SecureReliableMTOM 
</li>
          <li>
SecureReliableTransactedMTOM</li>
        </ul>
        <p>
The <font face="Courier New">Secure</font> binding uses WS-Security/WS-SecureConversation
pair to secure all outgoing and incoming messages using encryption and digital signing.
We’re not going to drill down into it in this post. I’m going to write another one
where different certificate mechanisms will be discussed.
</p>
        <p>
The <font face="Courier New">SecureReliable</font> binding also uses WS-ReliableMessaging
with message ordering and guaranteed delivery turned on.
</p>
        <p>
The <font face="Courier New">SecureReliableTransacted</font> endpoint also uses WS-AtomicTransaction
to implement transaction semantics between the client and the service.<br />
There are another three bindings (<font face="Courier New">*MTOM</font>) with the
same transport semantics as well as MTOM encoding turned on. Since services can support
transfer of large binary files, we have also set the <font face="Courier New">maxMessageSize</font> attribute
in every binding to 128 MB.
</p>
        <p>
Endpoint configuration for this service is:
</p>
        <p>
          <font face="Courier New">&lt;services&gt;<br />
  &lt;service<br />
    serviceType="Indigo.Demos.TransferService"<br />
    behaviorConfiguration="DefaultBehavior"&gt;<br />
    &lt;endpoint 
<br />
      address="</font>
          <a href="http://localhost:666/TransferService.svc/">
            <font face="Courier New">http://localhost:666/TransferService.svc/</font>
          </a>
          <font face="Courier New">" 
<br />
      bindingNamespace=<br />
        "</font>
          <a href="http://webservices.gama-system.com/bindings">
            <font face="Courier New">http://webservices.gama-system.com/bindings</font>
          </a>
          <font face="Courier New">" 
<br />
      bindingName="Default" 
<br />
      bindingSectionName="wsProfileBinding" 
<br />
      bindingConfiguration="SecureReliableMTOM" 
<br />
      contractType="Indigo.Demos.ITransferContract"/&gt;<br />
    &lt;endpoint 
<br />
      address=<br />
        "</font>
          <a href="http://localhost:666/TransferService.svc/secure">
            <font face="Courier New">http://localhost:666/TransferService.svc/secure</font>
          </a>
          <font face="Courier New">"<br />
      bindingNamespace=<br />
        "</font>
          <a href="http://webservices.gama-system.com/bindings">
            <font face="Courier New">http://webservices.gama-system.com/bindings</font>
          </a>
          <font face="Courier New">" 
<br />
      bindingName="Secure" 
<br />
      bindingSectionName="wsProfileBinding" 
<br />
      bindingConfiguration="Secure" 
<br />
      contractType="Indigo.Demos.ITransferContract"/&gt;<br />
    &lt;endpoint 
<br />
      address=<br />
        "</font>
          <a href="http://localhost:666/TransferService.svc/">
            <font face="Courier New">http://localhost:666/TransferService.svc/</font>
          </a>
          <br />
          <font face="Courier New">        securereliable" 
<br />
      bindingNamespace=<br />
        "</font>
          <a href="http://webservices.gama-system.com/bindings">
            <font face="Courier New">http://webservices.gama-system.com/bindings</font>
          </a>
          <font face="Courier New">" 
<br />
      bindingName="SecureReliable" 
<br />
      bindingSectionName="wsProfileBinding" 
<br />
      bindingConfiguration="SecureReliable" 
<br />
      contractType="Indigo.Demos.ITransferContract"/&gt;<br />
    &lt;endpoint 
<br />
      address=<br />
        "</font>
          <a href="http://localhost:666/TransferService.svc/">
            <font face="Courier New">http://localhost:666/TransferService.svc/</font>
          </a>
          <br />
          <font face="Courier New">          securereliabletransacted" 
<br />
      bindingNamespace=<br />
        "</font>
          <a href="http://webservices.gama-system.com/bindings">
            <font face="Courier New">http://webservices.gama-system.com/bindings</font>
          </a>
          <font face="Courier New">" 
<br />
      bindingName="SecureReliableTransacted" 
<br />
      bindingSectionName="wsProfileBinding" 
<br />
      bindingConfiguration="SecureReliableTransacted" 
<br />
      contractType="Indigo.Demos.ITransferContract"/&gt;<br />
    &lt;endpoint 
<br />
      address=<br />
        "</font>
          <a href="http://localhost:666/TransferService.svc/">
            <font face="Courier New">http://localhost:666/TransferService.svc/</font>
          </a>
          <br />
          <font face="Courier New">          secureMTOM" 
<br />
      bindingNamespace=<br />
        "</font>
          <a href="http://webservices.gama-system.com/bindings">
            <font face="Courier New">http://webservices.gama-system.com/bindings</font>
          </a>
          <font face="Courier New">" 
<br />
      bindingName="SecureMTOM" 
<br />
      bindingSectionName="wsProfileBinding" 
<br />
      bindingConfiguration="SecureMTOM" 
<br />
      contractType="Indigo.Demos.ITransferContract"/&gt;<br />
    &lt;endpoint 
<br />
      address=<br />
      "</font>
          <a href="http://localhost:666/TransferService.svc/">
            <font face="Courier New">http://localhost:666/TransferService.svc/</font>
          </a>
          <br />
          <font face="Courier New">        securereliableMTOM" 
<br />
      bindingNamespace=<br />
       "</font>
          <a href="http://webservices.gama-system.com/bindings">
            <font face="Courier New">http://webservices.gama-system.com/bindings</font>
          </a>
          <font face="Courier New">" 
<br />
      bindingName="SecureReliableMTOM" 
<br />
      bindingSectionName="wsProfileBinding" 
<br />
      bindingConfiguration="SecureReliableMTOM" 
<br />
      contractType="Indigo.Demos.ITransferContract"/&gt;<br />
    &lt;endpoint 
<br />
      address=<br />
        "</font>
          <a href="http://localhost:666/TransferService.svc/">
            <font face="Courier New">http://localhost:666/TransferService.svc/</font>
          </a>
          <br />
          <font face="Courier New">          securereliabletransactedMTOM" 
<br />
      bindingNamespace=<br />
        "</font>
          <a href="http://webservices.gama-system.com/bindings">
            <font face="Courier New">http://webservices.gama-system.com/bindings</font>
          </a>
          <font face="Courier New">" 
<br />
      bindingName="SecureReliableTransactedMTOM" 
<br />
      bindingSectionName="wsProfileBinding" 
<br />
      bindingConfiguration="SecureReliableTransactedMTOM" 
<br />
      contractType="Indigo.Demos.ITransferContract"/&gt;<br />
  &lt;/service&gt;<br />
&lt;/services&gt;</font>
        </p>
        <p>
It can be seen that almost every endpoint (two are bound to the same binding) is bound
to a different binding.<br />
The service is therefore exposing its functionality using the following endpoints:
</p>
        <ul>
          <li>
            <a href="http://localhost:666/TransferService.svc/">
              <font face="Courier New">http://localhost:666/TransferService.svc/</font>
            </a>
          </li>
          <li>
            <a href="http://localhost:666/TransferService.svc/secure">
              <font face="Courier New">http://localhost:666/TransferService.svc/secure</font>
            </a>
          </li>
          <li>
            <a href="http://localhost:666/TransferService.svc/securereliable">
              <font face="Courier New">http://localhost:666/TransferService.svc/securereliable</font>
            </a>
          </li>
          <li>
            <a href="http://localhost:666/TransferService.svc/securereliabletransacted">
              <font face="Courier New">http://localhost:666/TransferService.svc/securereliabletransacted</font>
            </a>
          </li>
          <li>
            <a href="http://localhost:666/TransferService.svc/secureMTOM">
              <font face="Courier New">http://localhost:666/TransferService.svc/secureMTOM</font>
            </a>
          </li>
          <li>
            <a href="http://localhost:666/TransferService.svc/securereliableMTOM">
              <font face="Courier New">http://localhost:666/TransferService.svc/securereliableMTOM</font>
            </a>
          </li>
          <li>
            <a href="http://localhost:666/TransferService.svc/securereliabletransactedMTOM">
              <font face="Courier New">http://localhost:666/TransferService.svc/securereliabletransactedMTOM</font>
            </a>
          </li>
        </ul>
        <p>
The first endpoint in this example is considered a default one and is mapped to the
same binding as the <font face="Courier New">*securereliableMTOM</font> endpoint.
</p>
        <p>
The problem with this is that current WCF’s WSDLExporter maps different endpoints
into WSDL ports, but WSDL ports have a requirement to be uniquely named. The default
port name construction is done by using the binding type name (i.e. <font face="Courier New">wsProfileBinding</font>, <font face="Courier New">basicProfileBinding</font>),
which is concatenated with the contract name.
</p>
        <p>
Therefore, when one has defined multiple bindings from the same binding type a name
collision occurs (six WSDL ports with the same QName (namespace and local name)).
This can be avoided using a <font face="Courier New">bindingNamespace</font> attribute
as well as <font face="Courier New">bindingName</font> attribute. In this example
we set the <font face="Courier New">bindingNamespace</font> to <a href="http://webservices.gama-system.com/bindings">http://webservices.gama-system.com/bindings</a> for
all bindings and made the name unique by using the bindingName attribute.
</p>
        <p>
There are currently two weird design decisions in multiple binding support of WCF.
First <font face="Courier New">bindingNamespace</font> and <font face="Courier New">bindingName</font> attributes
are bound to endpoints and not bindings. It would probably be more appropriate to
put binding’s namespace and name into the <font face="Courier New">&lt;binding&gt;</font> element.
Second, binding name is not propagated into WSDL properly when the same binding is
used in two or more endpoints (in this example <a href="http://localhost:666/TransferService.svc/">http://localhost:666/TransferService.svc/</a> and <a href="http://localhost:666/TransferService.svc/securereliableMTOM">http://localhost:666/TransferService.svc/securereliableMTOM</a> endpoints
are bound to <font face="Courier New">Default</font> binding. If you look closely
into the generated WSDL, you will see that the matching WSDL ports are not named after <font face="Courier New">bindingName</font> attribute.
</p>
        <p>
These are non-breaking issues and will probably be addressed for beta 2 of WCF.
</p>
        <p>
In the next Indigo series post, we’ll look closely into the security characteristics
of certificate based authentication.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=5371ff94-3412-4e41-87f7-3740c8e04ac4" />
      </body>
      <title>Indigo - Multiple endpoints</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,5371ff94-3412-4e41-87f7-3740c8e04ac4.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,5371ff94-3412-4e41-87f7-3740c8e04ac4.aspx</link>
      <pubDate>Fri, 12 Aug 2005 11:02:47 GMT</pubDate>
      <description>&lt;p&gt;
There is a common functionality request in modern distributed applications that clients
and services (client also being other services) could communicate using different
communication protocols and/or different transport semantics inside a single protocol.
&lt;/p&gt;
&lt;p&gt;
For this sample we're going to limit ourselves to HTTP messaging, but this does not
limit the scope of the article. Other transport protocols can be added without obstructing
other transport mechanisms.
&lt;/p&gt;
&lt;p&gt;
To allow this scenario Indigo (Windows Communication Foundation, WCF) allows multiple
endpoints per service to be setup. Service side bindings can, for example, be the
following:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;wsProfileBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; configurationName="Secure" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderedSession="false" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reliableSessionEnabled="false" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securityMode="WSSecurityOverHttp" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxMessageSize="134217728"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flowTransactions="NotAllowed"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messageEncoding="Text"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsSecurity 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authenticationMode="Certificate" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useNegotiation="true" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; configurationName="SecureReliable" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderedSession="true" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reliableSessionEnabled="true" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securityMode="WSSecurityOverHttp"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxMessageSize="134217728"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flowTransactions="NotAllowed"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messageEncoding="Text"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsSecurity&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authenticationMode="Certificate" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useNegotiation="true" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; configurationName="SecureReliableTransacted" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderedSession="true" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reliableSessionEnabled="true" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securityMode="WSSecurityOverHttp"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxMessageSize="134217728"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flowTransactions="Allowed"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messageEncoding="Text"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsSecurity 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authenticationMode="Certificate" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useNegotiation="true" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; configurationName="SecureMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderedSession="false" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reliableSessionEnabled="false" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securityMode="WSSecurityOverHttp" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxMessageSize="134217728"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flowTransactions="NotAllowed"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messageEncoding="Mtom"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsSecurity 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authenticationMode="Certificate" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useNegotiation="true" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;binding 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; configurationName="SecureReliableMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderedSession="true" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reliableSessionEnabled="true" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securityMode="WSSecurityOverHttp"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxMessageSize="134217728"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flowTransactions="NotAllowed"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messageEncoding="Mtom"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsSecurity 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authenticationMode="Certificate" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useNegotiation="true" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;binding&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; configurationName="SecureReliableTransactedMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderedSession="true" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reliableSessionEnabled="true" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securityMode="WSSecurityOverHttp"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxMessageSize="134217728"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flowTransactions="Allowed"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messageEncoding="Mtom"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsSecurity 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; authenticationMode="Certificate" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useNegotiation="true" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/wsProfileBinding&amp;gt;&lt;br&gt;
&amp;lt;/bindings&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
There are six different bindings setup:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Secure 
&lt;li&gt;
SecureReliable 
&lt;li&gt;
SecureReliableTransacted 
&lt;li&gt;
SecureMTOM 
&lt;li&gt;
SecureReliableMTOM 
&lt;li&gt;
SecureReliableTransactedMTOM&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The &lt;font face="Courier New"&gt;Secure&lt;/font&gt; binding uses WS-Security/WS-SecureConversation
pair to secure all outgoing and incoming messages using encryption and digital signing.
We’re not going to drill down into it in this post. I’m going to write another one
where different certificate mechanisms will be discussed.
&lt;/p&gt;
&lt;p&gt;
The &lt;font face="Courier New"&gt;SecureReliable&lt;/font&gt; binding also uses WS-ReliableMessaging
with message ordering and guaranteed delivery turned on.
&lt;/p&gt;
&lt;p&gt;
The &lt;font face="Courier New"&gt;SecureReliableTransacted&lt;/font&gt; endpoint also uses WS-AtomicTransaction
to implement transaction semantics between the client and the service.&lt;br&gt;
There are another three bindings (&lt;font face="Courier New"&gt;*MTOM&lt;/font&gt;) with the
same transport semantics as well as MTOM encoding turned on. Since services can support
transfer of large binary files, we have also set the &lt;font face="Courier New"&gt;maxMessageSize&lt;/font&gt; attribute
in every binding to 128 MB.
&lt;/p&gt;
&lt;p&gt;
Endpoint configuration for this service is:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;service&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; serviceType="Indigo.Demos.TransferService"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; behaviorConfiguration="DefaultBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address="&lt;/font&gt;&lt;a href="http://localhost:666/TransferService.svc/"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingNamespace=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://webservices.gama-system.com/bindings"&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/bindings&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingName="Default" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingSectionName="wsProfileBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration="SecureReliableMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType="Indigo.Demos.ITransferContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://localhost:666/TransferService.svc/secure"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/secure&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingNamespace=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://webservices.gama-system.com/bindings"&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/bindings&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingName="Secure" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingSectionName="wsProfileBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration="Secure" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType="Indigo.Demos.ITransferContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://localhost:666/TransferService.svc/"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/&lt;/font&gt;&lt;/a&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securereliable" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingNamespace=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://webservices.gama-system.com/bindings"&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/bindings&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingName="SecureReliable" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingSectionName="wsProfileBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration="SecureReliable" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType="Indigo.Demos.ITransferContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://localhost:666/TransferService.svc/"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/&lt;/font&gt;&lt;/a&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securereliabletransacted" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingNamespace=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://webservices.gama-system.com/bindings"&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/bindings&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingName="SecureReliableTransacted" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingSectionName="wsProfileBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration="SecureReliableTransacted" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType="Indigo.Demos.ITransferContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://localhost:666/TransferService.svc/"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/&lt;/font&gt;&lt;/a&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; secureMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingNamespace=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://webservices.gama-system.com/bindings"&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/bindings&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingName="SecureMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingSectionName="wsProfileBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration="SecureMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType="Indigo.Demos.ITransferContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://localhost:666/TransferService.svc/"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/&lt;/font&gt;&lt;/a&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securereliableMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingNamespace=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://webservices.gama-system.com/bindings"&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/bindings&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingName="SecureReliableMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingSectionName="wsProfileBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration="SecureReliableMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType="Indigo.Demos.ITransferContract"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://localhost:666/TransferService.svc/"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/&lt;/font&gt;&lt;/a&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; securereliabletransactedMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingNamespace=&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/font&gt;&lt;a href="http://webservices.gama-system.com/bindings"&gt;&lt;font face="Courier New"&gt;http://webservices.gama-system.com/bindings&lt;/font&gt;&lt;/a&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingName="SecureReliableTransactedMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingSectionName="wsProfileBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration="SecureReliableTransactedMTOM" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType="Indigo.Demos.ITransferContract"/&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/service&amp;gt;&lt;br&gt;
&amp;lt;/services&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
It can be seen that almost every endpoint (two are bound to the same binding) is bound
to a different binding.&lt;br&gt;
The service is therefore exposing its functionality using the following endpoints:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://localhost:666/TransferService.svc/"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/&lt;/font&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://localhost:666/TransferService.svc/secure"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/secure&lt;/font&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://localhost:666/TransferService.svc/securereliable"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/securereliable&lt;/font&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://localhost:666/TransferService.svc/securereliabletransacted"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/securereliabletransacted&lt;/font&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://localhost:666/TransferService.svc/secureMTOM"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/secureMTOM&lt;/font&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://localhost:666/TransferService.svc/securereliableMTOM"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/securereliableMTOM&lt;/font&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://localhost:666/TransferService.svc/securereliabletransactedMTOM"&gt;&lt;font face="Courier New"&gt;http://localhost:666/TransferService.svc/securereliabletransactedMTOM&lt;/font&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The first endpoint in this example is considered a default one and is mapped to the
same binding as the &lt;font face="Courier New"&gt;*securereliableMTOM&lt;/font&gt; endpoint.
&lt;/p&gt;
&lt;p&gt;
The problem with this is that current WCF’s WSDLExporter maps different endpoints
into WSDL ports, but WSDL ports have a requirement to be uniquely named. The default
port name construction is done by using the binding type name (i.e. &lt;font face="Courier New"&gt;wsProfileBinding&lt;/font&gt;, &lt;font face="Courier New"&gt;basicProfileBinding&lt;/font&gt;),
which is concatenated with the contract name.
&lt;/p&gt;
&lt;p&gt;
Therefore, when one has defined multiple bindings from the same binding type a name
collision occurs (six WSDL ports with the same QName (namespace and local name)).
This can be avoided using a &lt;font face="Courier New"&gt;bindingNamespace&lt;/font&gt; attribute
as well as &lt;font face="Courier New"&gt;bindingName&lt;/font&gt; attribute. In this example
we set the &lt;font face="Courier New"&gt;bindingNamespace&lt;/font&gt; to &lt;a href="http://webservices.gama-system.com/bindings"&gt;http://webservices.gama-system.com/bindings&lt;/a&gt; for
all bindings and made the name unique by using the bindingName attribute.
&lt;/p&gt;
&lt;p&gt;
There are currently two weird design decisions in multiple binding support of WCF.
First &lt;font face="Courier New"&gt;bindingNamespace&lt;/font&gt; and &lt;font face="Courier New"&gt;bindingName&lt;/font&gt; attributes
are bound to endpoints and not bindings. It would probably be more appropriate to
put binding’s namespace and name into the &lt;font face="Courier New"&gt;&amp;lt;binding&amp;gt;&lt;/font&gt; element.
Second, binding name is not propagated into WSDL properly when the same binding is
used in two or more endpoints (in this example &lt;a href="http://localhost:666/TransferService.svc/"&gt;http://localhost:666/TransferService.svc/&lt;/a&gt; and &lt;a href="http://localhost:666/TransferService.svc/securereliableMTOM"&gt;http://localhost:666/TransferService.svc/securereliableMTOM&lt;/a&gt; endpoints
are bound to &lt;font face="Courier New"&gt;Default&lt;/font&gt; binding. If you look closely
into the generated WSDL, you will see that the matching WSDL ports are not named after &lt;font face="Courier New"&gt;bindingName&lt;/font&gt; attribute.
&lt;/p&gt;
&lt;p&gt;
These are non-breaking issues and will probably be addressed for beta 2 of WCF.
&lt;/p&gt;
&lt;p&gt;
In the next Indigo series post, we’ll look closely into the security characteristics
of certificate based authentication.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=5371ff94-3412-4e41-87f7-3740c8e04ac4" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,5371ff94-3412-4e41-87f7-3740c8e04ac4.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>Transactions</category>
      <category>Web Services</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=23e1433d-8129-407f-926c-db34fc291f04</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,23e1433d-8129-407f-926c-db34fc291f04.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,23e1433d-8129-407f-926c-db34fc291f04.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=23e1433d-8129-407f-926c-db34fc291f04</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
While doing some serious Indigo development I noticed that a process was up and running
for a long period of time after any errors in the Indigo runtime occured.
</p>
        <p>
It was <font face="Courier New">dw20.exe</font>. Doctor Watson.
</p>
        <p>
Thank you Doctor, but I only read the brutal stack trace.
</p>
        <p>
So, if you're like me and don't care about sending specific self-induced pre-beta
technology error traces to Microsoft, do this:
</p>
        <ol>
          <li>
Open Control Panel/System</li>
          <li>
Goto Advanced tab</li>
          <li>
Click Error Reporting button</li>
          <li>
Disable error reporting</li>
          <li>
Disable critical error notifications</li>
        </ol>
        <p>
Indigo develoment is a lot more enjoyable now.
</p>
        <p>
I normally disable this anyway, but this was inside a Virtual Server image, and as
it goes, you learn it the hard way.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=23e1433d-8129-407f-926c-db34fc291f04" />
      </body>
      <title>Indigo Debugging</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,23e1433d-8129-407f-926c-db34fc291f04.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,23e1433d-8129-407f-926c-db34fc291f04.aspx</link>
      <pubDate>Thu, 21 Jul 2005 12:06:15 GMT</pubDate>
      <description>&lt;p&gt;
While doing some serious Indigo development I noticed that a process was up and running
for a long period of time&amp;nbsp;after any errors in the Indigo runtime occured.
&lt;/p&gt;
&lt;p&gt;
It was &lt;font face="Courier New"&gt;dw20.exe&lt;/font&gt;. Doctor Watson.
&lt;/p&gt;
&lt;p&gt;
Thank you Doctor, but I only read the brutal stack trace.
&lt;/p&gt;
&lt;p&gt;
So, if you're like me and don't care about sending specific self-induced pre-beta
technology error traces to Microsoft, do this:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Open Control Panel/System&lt;/li&gt;
&lt;li&gt;
Goto Advanced tab&lt;/li&gt;
&lt;li&gt;
Click Error Reporting button&lt;/li&gt;
&lt;li&gt;
Disable error reporting&lt;/li&gt;
&lt;li&gt;
Disable critical error notifications&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Indigo develoment is a lot more enjoyable now.
&lt;/p&gt;
&lt;p&gt;
I normally disable this anyway, but this was inside a Virtual Server image, and as
it goes, you learn it the hard way.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=23e1433d-8129-407f-926c-db34fc291f04" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,23e1433d-8129-407f-926c-db34fc291f04.aspx</comments>
      <category>.NET 3.0 - WCF</category>
      <category>Other</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=dce92b3c-c3f4-412d-a77a-81eb5c460524</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,dce92b3c-c3f4-412d-a77a-81eb5c460524.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,dce92b3c-c3f4-412d-a77a-81eb5c460524.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=dce92b3c-c3f4-412d-a77a-81eb5c460524</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A few days ago, Indigo + Avalon RC Beta 1 went live on MSDN.
</p>
        <p>
There are three packages to download, if you want to check out what's new in MSMQ
integration scenarios and especially queued channels.
</p>
        <ol>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B789BC8D-4F25-4823-B6AA-C5EDF432D0C1&amp;displaylang=en">Indigo
Runtime RC Beta 1</a>
          </li>
          <li>
            <a href="http://www.microsoft.com/downloads/info.aspx?u=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2F5%2F4%2F0%2F5407D6E4-740E-413E-8E91-EF7AC53A478A%2Fen_winfx_sdk_beta1_RC.iso&amp;amp;na=44&amp;amp;p=0&amp;amp;SrcDisplayLang=en&amp;amp;SrcCategoryId=&amp;amp;SrcFamilyId=b789bc8d-4f25-4823-b6aa-c5edf432d0c1&amp;amp;genscs=">WinFX
SDK RC Beta 1</a>
          </li>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?familyid=00e76c8a-e571-440e-929f-dc748136a886&amp;displaylang=en">MSMQ
3.5 Beta for Indigo</a>
          </li>
        </ol>
        <p>
While I don't want to get into a discussion on naming schemes (and yes, I do understand
that genuine Beta 1 is reserved for Longhorn Beta 1, but this is too much), these
three will give you an option to review what's been hidden on the MSMQ story.
</p>
        <p>
Things to consider:
</p>
        <ul>
          <li>
Try and install MSMQ 3.5 after native MSMQ support in Add/Remove Programs. It will
make your life easier.</li>
          <li>
Indigo RC Beta 1 will only work on official .NET Framework Beta 2. It will not
work on any previous CTPs.</li>
        </ul>
        <p>
Having that installed, we can write some MSMQ Indigo code. A simple calculator service
has a simple service contract:
</p>
        <p>
          <font face="Courier New">[ServiceContract]<br />
public interface ICanCalculate<br />
{<br />
  [OperationContract(IsOneWay=true)]<br />
  void CalcOp(Operation enmOp, int intA, int intB);<br />
}</font>
        </p>
        <p>
          <font face="Courier New">public enum Operation<br />
{<br />
  Add,<br />
  Subtract,<br />
  Multiply,<br />
  Divide<br />
}</font>
        </p>
        <p>
All messages are processed asynchronously, therefore <font face="Courier New">IsOneWay</font> should
be set to <font face="Courier New">true</font> on all operations. Any processing is
not done at invocation time, but rather at service processing time, which decouples
your client from your service. Service implementation, which implements <font face="Courier New">ICanCalculate</font> does
the obvious:
</p>
        <p>
          <font face="Courier New">public class CalculatorService : ICanCalculate 
<br />
{<br />
  [OperationBehavior(AutoEnlistTransaction=true, AutoCompleteTransaction=true)]<br />
  public void CalcOp(Operation enmOp, int intA, int intB) 
<br />
  {<br />
    int intResult = 0;<br />
    switch (enmOp)<br />
    {<br />
      case Operation.Add:<br />
        intResult = intA + intB;<br />
        break;<br />
      case Operation.Subtract:<br />
        intResult = intA - intB;<br />
        break;<br />
      case Operation.Multiply:<br />
        intResult = intA * intB;<br />
        break;<br />
      case Operation.Divide:<br />
        intResult = intA / intB;<br />
        break;<br />
      default:<br />
        throw new Exception("Invalid operation.");<br />
    }<br />
    Console.WriteLine("Received {0}({1}, {2}) - result: {3}", enmOp.ToString(),
intA, intB, intResult);<br />
}</font>
        </p>
        <p>
There's a <font face="Courier New">AutoCompleteTransaction</font> property set to <font face="Courier New">true</font> in <font face="Courier New">OperationBehaviour</font> attribute,
which automatically commits the transaction if no exceptions are thrown.
</p>
        <p>
Up till now, nothing is different from any basic Indigo service. What's beautiful
about Indigo architecture is that every single binding detail can be done via configuration.
MSMQ endpoint is therefore configured using the following config file:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br />
&lt;configuration xmlns="</font>
          <font face="Courier New">http://schemas.microsoft.com/.NetConfiguration/v2.0</font>
          <font face="Courier New">"&gt;<br />
 &lt;system.serviceModel&gt;<br />
  &lt;bindings&gt;<br />
   <strong>&lt;netProfileMsmqBinding&gt;</strong><br />
    &lt;binding configurationName = "MSMQBinding"<br />
       <strong>msmqAuthenticationMode = "None"</strong><br />
       <strong>msmqProtectionLevel = "None"/&gt;</strong><br />
   <strong>&lt;/netProfileMsmqBinding&gt;</strong><br />
  &lt;/bindings&gt;<br />
  &lt;services&gt;<br />
   &lt;service serviceType = "Indigo.Demos.CalculatorService"&gt;<br />
    &lt;endpoint <strong>address = "net.msmq://./private$/CalcQueue"</strong><br />
        bindingSectionName = "netProfileMsmqBinding"<br />
        bindingConfiguration = "MSMQBinding"<br />
        contractType = "Indigo.Demos.CalculatorService,
MSMQService"/&gt;<br />
   &lt;/service&gt;<br />
  &lt;/services&gt;<br />
 &lt;/system.serviceModel&gt;<br />
&lt;/configuration&gt;</font>
        </p>
        <p>
Setting <font face="Courier New">netProfileMsmqBinding</font> binding to this Indigo
service will cause the infrastructure to listen on the specified queue (<font face="Courier New">localhost/private$/CalcQueue</font>).
You must set authentication mode and protection level to none, if you're running in
MSMQ workgroup mode, since by default it uses an internal certificate (from AD) -
and therefore fails on other default security settings.
</p>
        <p>
We can use transaction semantics on the client which will cause to submit all-or-no
messages into the service queue:
</p>
        <p>
          <font face="Courier New">ChannelFactory&lt;IChannel&gt; cf = new ChannelFactory&lt;IChannel&gt;("EndpointConfig");<br />
ICanCalculate channel = cf.CreateChannel();<br /></font>
          <font face="Courier New">using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))<br />
{<br />
  int intA = 10;<br />
  int intB = 7;<br />
  channel.CalcOp(Operation.Add, intA, intB);<br />
  channel.CalcOp(Operation.Subtract, intA, intB);<br />
  channel.CalcOp(Operation.Multiply, intA, intB);<br />
  channel.CalcOp(Operation.Divide, intA, intB);<br />
  scope.Complete();<br />
}</font>
        </p>
        <p>
Client configuration should look like this:
</p>
        <p>
          <font face="Courier New">&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br />
&lt;configuration xmlns="</font>
          <font face="Courier New">http://schemas.microsoft.com/.NetConfiguration/v2.0</font>
          <font face="Courier New">"&gt;<br />
 &lt;system.serviceModel&gt;<br />
  &lt;bindings&gt;<br />
   &lt;netProfileMsmqBinding&gt;<br />
    &lt;binding configurationName="MSMQBinding"<br />
       msmqAuthenticationMode = "None"<br />
       msmqProtectionLevel = "None"/&gt;<br />
   &lt;/netProfileMsmqBinding&gt;<br />
  &lt;/bindings&gt;</font>
        </p>
        <p>
          <font face="Courier New">  &lt;client&gt;<br />
   &lt;endpoint address="net.msmq://./private$/CalcQueue" 
<br />
                     
bindingSectionName="netProfileMsmqBinding" 
<br />
                     
bindingConfiguration="MSMQBinding" 
<br />
       contractType="Indigo.Demos.ICanCalculate"<br />
       configurationName="EndpointConfig"/&gt;<br />
        &lt;/client&gt;<br />
 &lt;/system.serviceModel&gt;<br />
&lt;/configuration&gt;</font>
        </p>
        <p>
Client and service are now totally independent. You can send arbitrary number of requests
to the service side and they will land in the MSMQ queue. Your service does not need
to be running at the same time your client is. When it gets back up, all existing
messages will get processed automatically.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=dce92b3c-c3f4-412d-a77a-81eb5c460524" />
      </body>
      <title>Indigo: MSMQ Support, Queued Channels</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,dce92b3c-c3f4-412d-a77a-81eb5c460524.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,dce92b3c-c3f4-412d-a77a-81eb5c460524.aspx</link>
      <pubDate>Tue, 24 May 2005 20:28:16 GMT</pubDate>
      <description>&lt;p&gt;
A few days ago, Indigo + Avalon RC Beta 1 went live on MSDN.
&lt;/p&gt;
&lt;p&gt;
There are three packages to download, if you want to check out what's new in MSMQ
integration scenarios and especially queued channels.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B789BC8D-4F25-4823-B6AA-C5EDF432D0C1&amp;amp;displaylang=en"&gt;Indigo
Runtime RC Beta 1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.microsoft.com/downloads/info.aspx?u=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2F5%2F4%2F0%2F5407D6E4-740E-413E-8E91-EF7AC53A478A%2Fen_winfx_sdk_beta1_RC.iso&amp;amp;amp;na=44&amp;amp;amp;p=0&amp;amp;amp;SrcDisplayLang=en&amp;amp;amp;SrcCategoryId=&amp;amp;amp;SrcFamilyId=b789bc8d-4f25-4823-b6aa-c5edf432d0c1&amp;amp;amp;genscs="&gt;WinFX
SDK RC Beta 1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=00e76c8a-e571-440e-929f-dc748136a886&amp;amp;displaylang=en"&gt;MSMQ
3.5 Beta for Indigo&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
While I don't want to get into a discussion on naming schemes (and yes, I do understand
that genuine Beta 1 is reserved for Longhorn Beta 1, but this is too much), these
three will give you an option to&amp;nbsp;review what's been hidden on the MSMQ story.
&lt;/p&gt;
&lt;p&gt;
Things to consider:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Try and install MSMQ 3.5 after native MSMQ support in Add/Remove Programs. It will
make your life easier.&lt;/li&gt;
&lt;li&gt;
Indigo RC Beta 1 will only work on official&amp;nbsp;.NET Framework Beta 2. It will not
work on any previous CTPs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Having that installed, we can write some MSMQ Indigo code. A simple calculator service
has a simple service contract:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[ServiceContract]&lt;br&gt;
public interface ICanCalculate&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; [OperationContract(IsOneWay=true)]&lt;br&gt;
&amp;nbsp; void CalcOp(Operation enmOp, int intA, int intB);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;public enum Operation&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; Add,&lt;br&gt;
&amp;nbsp; Subtract,&lt;br&gt;
&amp;nbsp; Multiply,&lt;br&gt;
&amp;nbsp; Divide&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
All messages are processed asynchronously, therefore &lt;font face="Courier New"&gt;IsOneWay&lt;/font&gt; should
be set to &lt;font face="Courier New"&gt;true&lt;/font&gt; on all operations. Any processing is
not done at invocation time, but rather at service processing time, which decouples
your client from your service. Service implementation, which implements &lt;font face="Courier New"&gt;ICanCalculate&lt;/font&gt; does
the obvious:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;public class CalculatorService : ICanCalculate 
&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; [OperationBehavior(AutoEnlistTransaction=true, AutoCompleteTransaction=true)]&lt;br&gt;
&amp;nbsp; public void CalcOp(Operation enmOp, int intA, int intB) 
&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int intResult = 0;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (enmOp)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case Operation.Add:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intResult = intA + intB;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case Operation.Subtract:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intResult = intA - intB;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case Operation.Multiply:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intResult = intA * intB;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case Operation.Divide:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intResult = intA / intB;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; default:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new Exception("Invalid operation.");&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("Received {0}({1}, {2}) - result: {3}", enmOp.ToString(),
intA, intB, intResult);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
There's a &lt;font face="Courier New"&gt;AutoCompleteTransaction&lt;/font&gt; property set to &lt;font face="Courier New"&gt;true&lt;/font&gt;&amp;nbsp;in &lt;font face="Courier New"&gt;OperationBehaviour&lt;/font&gt; attribute,
which automatically commits the transaction if no exceptions are thrown.
&lt;/p&gt;
&lt;p&gt;
Up till now, nothing is different from any basic Indigo service. What's beautiful
about Indigo architecture is that every single binding detail can be done via configuration.
MSMQ endpoint is therefore configured using the following config file:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;br&gt;
&amp;lt;configuration xmlns="&lt;/font&gt;&lt;font face="Courier New"&gt;http://schemas.microsoft.com/.NetConfiguration/v2.0&lt;/font&gt;&lt;font face="Courier New"&gt;"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;&amp;lt;netProfileMsmqBinding&amp;gt;&lt;/strong&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;binding configurationName = "MSMQBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;msmqAuthenticationMode = "None"&lt;/strong&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;msmqProtectionLevel = "None"/&amp;gt;&lt;/strong&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;&amp;lt;/netProfileMsmqBinding&amp;gt;&lt;/strong&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;lt;/bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;service serviceType = "Indigo.Demos.CalculatorService"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;endpoint &lt;strong&gt;address = "net.msmq://./private$/CalcQueue"&lt;/strong&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingSectionName = "netProfileMsmqBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindingConfiguration = "MSMQBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType = "Indigo.Demos.CalculatorService,
MSMQService"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/service&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;lt;/services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;lt;/system.serviceModel&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Setting &lt;font face="Courier New"&gt;netProfileMsmqBinding&lt;/font&gt; binding to this Indigo
service will cause the infrastructure to listen on the specified queue (&lt;font face="Courier New"&gt;localhost/private$/CalcQueue&lt;/font&gt;).
You must set authentication mode and protection level to none, if you're running in
MSMQ workgroup mode, since by default it uses an internal certificate (from AD) -
and therefore fails on other default security settings.
&lt;/p&gt;
&lt;p&gt;
We can use transaction semantics on the client which will cause to submit all-or-no
messages into the service queue:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;ChannelFactory&amp;lt;IChannel&amp;gt; cf = new ChannelFactory&amp;lt;IChannel&amp;gt;("EndpointConfig");&lt;br&gt;
ICanCalculate channel = cf.CreateChannel();&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; int intA = 10;&lt;br&gt;
&amp;nbsp; int intB = 7;&lt;br&gt;
&amp;nbsp; channel.CalcOp(Operation.Add, intA, intB);&lt;br&gt;
&amp;nbsp; channel.CalcOp(Operation.Subtract, intA, intB);&lt;br&gt;
&amp;nbsp; channel.CalcOp(Operation.Multiply, intA, intB);&lt;br&gt;
&amp;nbsp; channel.CalcOp(Operation.Divide, intA, intB);&lt;br&gt;
&amp;nbsp; scope.Complete();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Client configuration should look like this:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;br&gt;
&amp;lt;configuration xmlns="&lt;/font&gt;&lt;font face="Courier New"&gt;http://schemas.microsoft.com/.NetConfiguration/v2.0&lt;/font&gt;&lt;font face="Courier New"&gt;"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;netProfileMsmqBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;binding configurationName="MSMQBinding"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msmqAuthenticationMode = "None"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msmqProtectionLevel = "None"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/netProfileMsmqBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;lt;/bindings&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;lt;client&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;endpoint address="net.msmq://./private$/CalcQueue" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bindingSectionName="netProfileMsmqBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bindingConfiguration="MSMQBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contractType="Indigo.Demos.ICanCalculate"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; configurationName="EndpointConfig"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/client&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;lt;/system.serviceModel&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Client and service are now totally independent. You can send arbitrary number of requests
to the service side and they will land in the MSMQ queue. Your service does not need
to be running at the same time your client is. When it gets back up, all existing
messages will get processed automatically.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=dce92b3c-c3f4-412d-a77a-81eb5c460524" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,dce92b3c-c3f4-412d-a77a-81eb5c460524.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
    <item>
      <trackback:ping>https://www.request-response.com/blog/Trackback.aspx?guid=48b65a92-4015-45f2-8fee-78ae5c0e48b8</trackback:ping>
      <pingback:server>https://www.request-response.com/blog/pingback.aspx</pingback:server>
      <pingback:target>https://www.request-response.com/blog/PermaLink,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx</pingback:target>
      <dc:creator>Matevz Gacnik</dc:creator>
      <wfw:comment>https://www.request-response.com/blog/CommentView,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx</wfw:comment>
      <wfw:commentRss>https://www.request-response.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=48b65a92-4015-45f2-8fee-78ae5c0e48b8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The following service will allow you to check how Indigo instancing behaviour works:
</p>
        <p>
          <font face="Courier New">using System;<br />
using System.ServiceModel;</font>
        </p>
        <p>
          <font face="Courier New">[ServiceContract]<br />
interface ICanRandom<br />
{<br />
 [OperationContract]<br />
 int Randomize(int intLow, int intHigh);</font>
        </p>
        <p>
          <font face="Courier New"> [OperationContract]<br />
 int GetLastNumber();<br />
}</font>
        </p>
        <p>
          <font face="Courier New">[ServiceBehavior(InstanceMode = InstanceMode.Singleton, ConcurrencyMode
= ConcurrencyMode.Multiple)]<br />
public class RandomizerService : ICanRandom<br />
{<br />
 private int intLastNumber;<br />
 private Random r = new Random(DateTime.Now.Millisecond);</font>
        </p>
        <p>
          <font face="Courier New"> public int Randomize(int intLow, int intHigh)<br />
 {<br />
  System.Threading.Thread.Sleep(5000);<br />
  int intRandomNumber = r.Next(intLow, intHigh);<br />
  intLastNumber = intRandomNumber;<br />
  return intRandomNumber;<br />
 }</font>
        </p>
        <p>
          <font face="Courier New"> public int GetLastNumber()<br />
 {<br />
  return intLastNumber;<br />
 }<br />
}</font>
        </p>
        <p>
This service will return a random number for multiple clients. Try simulating it with
the following client code:
</p>
        <p>
          <font face="Courier New">using System;<br />
using System.Threading;</font>
        </p>
        <p>
          <font face="Courier New">class Program<br />
{<br />
 static void Main(string[] args)<br />
 {<br />
  Thread t1 = new Thread(new ParameterizedThreadStart(Program.CallService));<br />
  Thread t2 = new Thread(new ParameterizedThreadStart(Program.CallService));<br />
  Console.WriteLine("Threads running.");<br />
  t1.Start(1);<br />
  t2.Start(2);<br />
 }</font>
        </p>
        <p>
          <font face="Courier New"> static void CallService(object intThread)<br />
 {<br />
  CanRandomProxy objWS = new CanRandomProxy("ICanRandom");<br />
  Console.WriteLine("Thread {0} - Method call.", intThread);<br />
  Console.WriteLine("Thread {0} - Random number: {1}", intThread, objWS.Randomize(10,
110));<br />
  Console.WriteLine("Thread {0} - Last random number: {1}", intThread, objWS.GetLastNumber());<br />
  Console.WriteLine("Thread {0} - Done.", intThread);<br />
 }<br />
}</font>
        </p>
        <p>
Singleton services process all requests using a single service instance. Try changing
the <font face="Courier New">ConcurrencyMode</font> property of <font face="Courier New">ServiceBehaviour </font>attribute
to obtain different instancing semantics. Having <font face="Courier New">InstanceMode</font> set
to <font face="Courier New">PerCall</font> (current default) will disable <font face="Courier New">ConcurrencyMode.Multiple</font> behaviour,
which is expected.
</p>
        <img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=48b65a92-4015-45f2-8fee-78ae5c0e48b8" />
      </body>
      <title>Indigo - Instancing</title>
      <guid isPermaLink="false">https://www.request-response.com/blog/PermaLink,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx</guid>
      <link>https://www.request-response.com/blog/PermaLink,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx</link>
      <pubDate>Sun, 27 Mar 2005 20:04:33 GMT</pubDate>
      <description>&lt;p&gt;
The following service will allow you to check how Indigo instancing behaviour works:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;using System;&lt;br&gt;
using System.ServiceModel;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[ServiceContract]&lt;br&gt;
interface ICanRandom&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;[OperationContract]&lt;br&gt;
&amp;nbsp;int Randomize(int intLow, int intHigh);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;[OperationContract]&lt;br&gt;
&amp;nbsp;int GetLastNumber();&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[ServiceBehavior(InstanceMode = InstanceMode.Singleton, ConcurrencyMode
= ConcurrencyMode.Multiple)]&lt;br&gt;
public class RandomizerService : ICanRandom&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;private int intLastNumber;&lt;br&gt;
&amp;nbsp;private Random r = new Random(DateTime.Now.Millisecond);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;public int Randomize(int intLow, int intHigh)&lt;br&gt;
&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;System.Threading.Thread.Sleep(5000);&lt;br&gt;
&amp;nbsp;&amp;nbsp;int intRandomNumber = r.Next(intLow, intHigh);&lt;br&gt;
&amp;nbsp;&amp;nbsp;intLastNumber = intRandomNumber;&lt;br&gt;
&amp;nbsp;&amp;nbsp;return intRandomNumber;&lt;br&gt;
&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;public int GetLastNumber()&lt;br&gt;
&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;return intLastNumber;&lt;br&gt;
&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This service will return a random number for multiple clients. Try simulating it with
the following client code:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;using System;&lt;br&gt;
using System.Threading;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;class Program&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;static void Main(string[] args)&lt;br&gt;
&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;Thread t1 = new Thread(new ParameterizedThreadStart(Program.CallService));&lt;br&gt;
&amp;nbsp;&amp;nbsp;Thread t2 = new Thread(new ParameterizedThreadStart(Program.CallService));&lt;br&gt;
&amp;nbsp;&amp;nbsp;Console.WriteLine("Threads running.");&lt;br&gt;
&amp;nbsp;&amp;nbsp;t1.Start(1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;t2.Start(2);&lt;br&gt;
&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;static void CallService(object intThread)&lt;br&gt;
&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;CanRandomProxy objWS = new CanRandomProxy("ICanRandom");&lt;br&gt;
&amp;nbsp;&amp;nbsp;Console.WriteLine("Thread {0} - Method call.", intThread);&lt;br&gt;
&amp;nbsp;&amp;nbsp;Console.WriteLine("Thread {0} - Random number: {1}", intThread, objWS.Randomize(10,
110));&lt;br&gt;
&amp;nbsp;&amp;nbsp;Console.WriteLine("Thread {0} - Last random number: {1}", intThread, objWS.GetLastNumber());&lt;br&gt;
&amp;nbsp;&amp;nbsp;Console.WriteLine("Thread {0} - Done.", intThread);&lt;br&gt;
&amp;nbsp;}&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Singleton services process all requests using a single service instance. Try changing
the &lt;font face="Courier New"&gt;ConcurrencyMode&lt;/font&gt; property of &lt;font face="Courier New"&gt;ServiceBehaviour &lt;/font&gt;attribute
to obtain different instancing semantics. Having &lt;font face="Courier New"&gt;InstanceMode&lt;/font&gt; set
to &lt;font face="Courier New"&gt;PerCall&lt;/font&gt; (current default) will disable &lt;font face="Courier New"&gt;ConcurrencyMode.Multiple&lt;/font&gt; behaviour,
which is expected.
&lt;/p&gt;
&lt;img width="0" height="0" src="https://www.request-response.com/blog/aggbug.ashx?id=48b65a92-4015-45f2-8fee-78ae5c0e48b8" /&gt;</description>
      <comments>https://www.request-response.com/blog/CommentView,guid,48b65a92-4015-45f2-8fee-78ae5c0e48b8.aspx</comments>
      <category>.NET 3.0 - WCF</category>
    </item>
  </channel>
</rss>