<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>REST</title>
        <link>http://www.rickgaribay.net/category/48.aspx</link>
        <description>REST</description>
        <language>en-US</language>
        <copyright>Rick G. Garibay</copyright>
        <managingEditor>rick@rickgaribay.net</managingEditor>
        <generator>Subtext Version 1.9.5.176</generator>
        <item>
            <title>Common Service Bus Queue Operations with the REST API</title>
            <link>http://rickgaribay.net/archive/2012/01/19/common-service-bus-queue-operations-with-the-rest-api.aspx</link>
            <description>&lt;p&gt;Azure Service Bus Brokered Messaging provides durable pull-based pub-sub, complimenting it’s older sibling Relay Messaging which uses a push messaging model. While both enable hybrid composition across traditional business, trust and network boundaries, they provide unique capabilities in and of themselves. &lt;/p&gt;  &lt;p&gt;As with Relay Messaging, Brokered Messaging provides first class support for WCF with the NetMessagingBinding, but expands the developer surface to general .NET and cross-platform/mobility scenarios by offering the .NET Client and REST API respectively.&lt;/p&gt;  &lt;p&gt;Of the 3 APIs, the .NET Client API is the most robust and seems to be the most documented.&lt;/p&gt;  &lt;p&gt;The simplicity of the WCF programming model (the illusion that messages are being pushed to your endpoint) is balanced with some restrictions that naturally fall out of the scope of one-way messaging including queue/topic/subscription/rule creation and support for peek lock.&lt;/p&gt;  &lt;p&gt;In this regard, while not as robust as the .NET Client API, the REST API offers a more comprehensive feature set and when working on solutions that must be interoperable across client platforms or due to other restrictions, the REST API is a great choice.&lt;/p&gt;  &lt;p&gt;Microsoft has documented the REST API in the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh367521.aspx#BKMK_REST5prod" target="_blank"&gt;Service Bus REST API Reference&lt;/a&gt;, but there are not a ton of imperative examples out there that show WebClient or HttpWebRequest, so the purpose of this post is to share some nitty gritty examples of how to get some of the most common operations done in C#.&lt;/p&gt;  &lt;p&gt;Please note that my goal is not to be elegant or use the tersest or most fluid syntax possible in this samples, but rather to get some quick and dirty examples out there, well, quickly. &lt;/p&gt;  &lt;p&gt;As such, the unit tests should be self explanatory, but if you have any questions, please don’t hesitate to ask. &lt;/p&gt;  &lt;p&gt;Feedback, comments related to the API or WebClient techniques welcome &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://rickgaribay.net/Images/customcontent/Common-Service-Bus-Patterns-with-the-RES_795D/wlEmoticon-smile.png" /&gt;&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.VisualStudio.TestTools.UnitTesting;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Specialized;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Net;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Runtime.Serialization.Json;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Runtime.Serialization;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; RESTAPITests&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    [TestClass]&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RESTAPITests&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; serviceNamespace = &lt;span class="str"&gt;"[NAMESPACE]"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; issuerName = &lt;span class="str"&gt;"owner"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; issuerSecret = &lt;span class="str"&gt;"[KEY]"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;        &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; sbHostName = &lt;span class="str"&gt;"servicebus.windows.net"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;        &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; acsHostName = &lt;span class="str"&gt;"accesscontrol.windows.net"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; relativeAddress = &lt;span class="str"&gt;"[Queue]"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; baseAddress;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;        &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;        [TestMethod]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendMessageShouldSucceedWithoutError()&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; body = &lt;span class="str"&gt;"foo"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            var token = GetToken(issuerName, issuerSecret);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;            baseAddress = GetBaseAddress();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; fullAddress = baseAddress + relativeAddress + &lt;span class="str"&gt;"/messages"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;            WebClient webClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;            webClient.Headers[HttpRequestHeader.Authorization] = token;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;            webClient.UploadData(fullAddress, &lt;span class="str"&gt;"POST"&lt;/span&gt;, Encoding.UTF8.GetBytes(body));   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;        [TestMethod]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PeekLockMessageShouldReturnLockId()&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;            var token = GetToken(issuerName, issuerSecret);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;            baseAddress = GetBaseAddress();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  50:  &lt;/span&gt;            &lt;span class="rem"&gt;// Read and lock the message. Unless released, the lock will expire within the configured lock duration (on the queue)&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  51:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; fullAddress = baseAddress + relativeAddress + &lt;span class="str"&gt;"/messages/head"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  52:  &lt;/span&gt;           &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  53:  &lt;/span&gt;            WebClient webClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  54:  &lt;/span&gt;            webClient.Headers[HttpRequestHeader.Authorization] = token;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  55:  &lt;/span&gt;            webClient.UploadData(fullAddress, &lt;span class="str"&gt;"POST"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[0]{});&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  56:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  57:  &lt;/span&gt;            var props = webClient.ResponseHeaders[&lt;span class="str"&gt;"BrokerProperties"&lt;/span&gt;];&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  58:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  59:  &lt;/span&gt;            &lt;span class="rem"&gt;// Deserialize the JSON header to a simple class&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  60:  &lt;/span&gt;            DataContractJsonSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataContractJsonSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(BrokerProperty));&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  61:  &lt;/span&gt;            &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream(Encoding.Unicode.GetBytes(props)))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  62:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  63:  &lt;/span&gt;                var result = (BrokerProperty)serializer.ReadObject(stream);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  64:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  65:  &lt;/span&gt;                Assert.IsNotNull(result.LockToken); &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  66:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  67:  &lt;/span&gt;    &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  68:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  69:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  70:  &lt;/span&gt;        [TestMethod]&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  71:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PeekLockMessageAndAbandonShouldSucceed()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  72:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  73:  &lt;/span&gt;            var token = GetToken(issuerName, issuerSecret);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  74:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  75:  &lt;/span&gt;            baseAddress = GetBaseAddress();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  76:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  77:  &lt;/span&gt;            &lt;span class="rem"&gt;// Read and lock the message. Unless released, the lock will expire within the configured lock duration (on the queue)&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  78:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; fullAddress = baseAddress + relativeAddress + &lt;span class="str"&gt;"/messages/head"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  79:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  80:  &lt;/span&gt;            WebClient webClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  81:  &lt;/span&gt;            webClient.Headers[HttpRequestHeader.Authorization] = token;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  82:  &lt;/span&gt;            webClient.UploadData(fullAddress, &lt;span class="str"&gt;"POST"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[0] { });&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  83:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  84:  &lt;/span&gt;            var props = webClient.ResponseHeaders[&lt;span class="str"&gt;"BrokerProperties"&lt;/span&gt;];&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  85:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  86:  &lt;/span&gt;            &lt;span class="rem"&gt;// Deserialize the JSON header to a simple class&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  87:  &lt;/span&gt;            DataContractJsonSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataContractJsonSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(BrokerProperty));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  88:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  89:  &lt;/span&gt;            &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream(Encoding.Unicode.GetBytes(props)))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  90:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  91:  &lt;/span&gt;                var result = (BrokerProperty)serializer.ReadObject(stream);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  92:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  93:  &lt;/span&gt;                &lt;span class="rem"&gt;// Bail on the message, release the lock so it is available for another consumer&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  94:  &lt;/span&gt;                fullAddress = baseAddress + relativeAddress + String.Format(&lt;span class="str"&gt;"/messages/{0}/{1}"&lt;/span&gt;, result.MessageId, result.LockToken);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  95:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  96:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  97:  &lt;/span&gt;            webClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  98:  &lt;/span&gt;            webClient.Headers[HttpRequestHeader.Authorization] = token;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  99:  &lt;/span&gt;            webClient.UploadData(fullAddress, &lt;span class="str"&gt;"PUT"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[0] { });&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 100:  &lt;/span&gt;           &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 101:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 102:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 103:  &lt;/span&gt;        [TestMethod]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 104:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PeekLockMessageAndCompleteShouldSucceed()&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 105:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 106:  &lt;/span&gt;            var token = GetToken(issuerName, issuerSecret);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 107:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 108:  &lt;/span&gt;            baseAddress = GetBaseAddress();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 109:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 110:  &lt;/span&gt;            &lt;span class="rem"&gt;// Peek lock the message&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 111:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; fullAddress = baseAddress + relativeAddress + &lt;span class="str"&gt;"/messages/head"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 112:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 113:  &lt;/span&gt;            WebClient webClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 114:  &lt;/span&gt;            webClient.Headers[HttpRequestHeader.Authorization] = token;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 115:  &lt;/span&gt;            webClient.UploadData(fullAddress, &lt;span class="str"&gt;"POST"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[0] { });&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 116:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 117:  &lt;/span&gt;            var props = webClient.ResponseHeaders[&lt;span class="str"&gt;"BrokerProperties"&lt;/span&gt;];&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 118:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 119:  &lt;/span&gt;            DataContractJsonSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataContractJsonSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(BrokerProperty));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 120:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 121:  &lt;/span&gt;            &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream(Encoding.Unicode.GetBytes(props)))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 122:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 123:  &lt;/span&gt;                var result = (BrokerProperty)serializer.ReadObject(stream);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 124:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 125:  &lt;/span&gt;                &lt;span class="rem"&gt;// Complete the read operation, releasing the lock and deleting the message from the queue&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 126:  &lt;/span&gt;                fullAddress = baseAddress + relativeAddress + String.Format(&lt;span class="str"&gt;"/messages/{0}/{1}"&lt;/span&gt;, result.MessageId, result.LockToken);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 127:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 128:  &lt;/span&gt;            webClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 129:  &lt;/span&gt;            webClient.Headers[HttpRequestHeader.Authorization] = token;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 130:  &lt;/span&gt;            webClient.UploadData(fullAddress, &lt;span class="str"&gt;"DELETE"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[0] { });&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 131:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 132:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 133:  &lt;/span&gt;        [TestMethod]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 134:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DecodeJsonToTypeShouldAllowEasyExtractionOfProps()&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 135:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 136:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;p&gt;&lt;span class="lnum"&gt; 137:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; payload = &lt;span class="str"&gt;@"{"&lt;/span&gt;&lt;span class="str"&gt;"DeliveryCount"&lt;/span&gt;&lt;span class="str"&gt;":3,"&lt;/span&gt;&lt;span class="str"&gt;"LockToken"&lt;/span&gt;&lt;span class="str"&gt;":"&lt;/span&gt;&lt;span class="str"&gt;"4a1d4c96-9837-42a9-ad91-3ecf704eec40"&lt;/span&gt;&lt;span class="str"&gt;","&lt;/span&gt;&lt;span class="str"&gt;"LockedUntilUtc"&lt;/span&gt;&lt;span class="str"&gt;":"&lt;/span&gt;&lt;span class="str"&gt;"Thu, 19 Jan 2012 01:22:44 GMT"&lt;/span&gt;&lt;span class="str"&gt;",&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="str"&gt;                                    &lt;/span&gt;&lt;span class="str"&gt;"&lt;/span&gt;&lt;span class="str"&gt;"MessageId"&lt;/span&gt;&lt;span class="str"&gt;":"&lt;/span&gt;&lt;span class="str"&gt;"4a4fa2c7d87a40a7b799625b9de69e42"&lt;/span&gt;&lt;span class="str"&gt;","&lt;/span&gt;&lt;span class="str"&gt;"SequenceNumber"&lt;/span&gt;&lt;span class="str"&gt;":2,"&lt;/span&gt;&lt;span class="str"&gt;"TimeToLive"&lt;/span&gt;&lt;span class="str"&gt;":922337203685}"&lt;/span&gt;;&lt;/p&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 138:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 139:  &lt;/span&gt;            DataContractJsonSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataContractJsonSerializer(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(BrokerProperty));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 140:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 141:  &lt;/span&gt;            &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream(Encoding.Unicode.GetBytes(payload)))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 142:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 143:  &lt;/span&gt;                var result = (BrokerProperty)serializer.ReadObject(stream);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 144:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 145:  &lt;/span&gt;                Assert.IsNotNull(result.MessageId);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 146:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 147:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 148:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 149:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 150:  &lt;/span&gt;        [DataContract]&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 151:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; BrokerProperty&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 152:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 153:  &lt;/span&gt;            [DataMember]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 154:  &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; DeliveryCount { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 155:  &lt;/span&gt;            [DataMember]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 156:  &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; LockToken { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 157:  &lt;/span&gt;            [DataMember]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 158:  &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; LockedUntilUtc { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 159:  &lt;/span&gt;            [DataMember]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 160:  &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; MessageId { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 161:  &lt;/span&gt;            [DataMember]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 162:  &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SequenceNumber { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 163:  &lt;/span&gt;            [DataMember]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 164:  &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; TimeToLive { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 165:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 166:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 167:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 168:  &lt;/span&gt;        &lt;span class="rem"&gt;// Helper&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 169:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetBaseAddress()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 170:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 171:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; baseAddress = &lt;span class="str"&gt;"https://"&lt;/span&gt; + serviceNamespace + &lt;span class="str"&gt;"."&lt;/span&gt; + sbHostName + &lt;span class="str"&gt;"/"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 172:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 173:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 174:  &lt;/span&gt;        &lt;span class="rem"&gt;// Helper, warmly borrowed from Service Bus Management Sample :-)&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 175:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetToken(&lt;span class="kwrd"&gt;string&lt;/span&gt; issuerName, &lt;span class="kwrd"&gt;string&lt;/span&gt; issuerSecret)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 176:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 177:  &lt;/span&gt;            var acsEndpoint = &lt;span class="str"&gt;"https://"&lt;/span&gt; + serviceNamespace + &lt;span class="str"&gt;"-sb."&lt;/span&gt; + acsHostName + &lt;span class="str"&gt;"/WRAPv0.9/"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 178:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 179:  &lt;/span&gt;            &lt;span class="rem"&gt;// Note that the realm used when requesting a token uses the HTTP scheme, even though&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 180:  &lt;/span&gt;            &lt;span class="rem"&gt;// calls to the service are always issued over HTTPS&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 181:  &lt;/span&gt;            var realm = &lt;span class="str"&gt;"http://"&lt;/span&gt; + serviceNamespace + &lt;span class="str"&gt;"."&lt;/span&gt; + sbHostName + &lt;span class="str"&gt;"/"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 182:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 183:  &lt;/span&gt;            NameValueCollection values = &lt;span class="kwrd"&gt;new&lt;/span&gt; NameValueCollection();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 184:  &lt;/span&gt;            values.Add(&lt;span class="str"&gt;"wrap_name"&lt;/span&gt;, issuerName);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 185:  &lt;/span&gt;            values.Add(&lt;span class="str"&gt;"wrap_password"&lt;/span&gt;, issuerSecret);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 186:  &lt;/span&gt;            values.Add(&lt;span class="str"&gt;"wrap_scope"&lt;/span&gt;, realm);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 187:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 188:  &lt;/span&gt;            WebClient webClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 189:  &lt;/span&gt;            &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] response = webClient.UploadValues(acsEndpoint, values);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 190:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 191:  &lt;/span&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; responseString = Encoding.UTF8.GetString(response);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 192:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 193:  &lt;/span&gt;            var responseProperties = responseString.Split(&lt;span class="str"&gt;'&amp;amp;'&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 194:  &lt;/span&gt;            var tokenProperty = responseProperties[0].Split(&lt;span class="str"&gt;'='&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 195:  &lt;/span&gt;            var token = Uri.UnescapeDataString(tokenProperty[1]);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 196:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 197:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;"WRAP access_token=\""&lt;/span&gt; + token + &lt;span class="str"&gt;"\""&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 198:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 199:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 200:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 201:  &lt;/span&gt;    &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt; 202:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;img src="http://rickgaribay.net/aggbug/326.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rick G. Garibay</dc:creator>
            <guid>http://rickgaribay.net/archive/2012/01/19/common-service-bus-queue-operations-with-the-rest-api.aspx</guid>
            <pubDate>Thu, 19 Jan 2012 16:23:08 GMT</pubDate>
            <comments>http://rickgaribay.net/archive/2012/01/19/common-service-bus-queue-operations-with-the-rest-api.aspx#feedback</comments>
            <wfw:commentRss>http://rickgaribay.net/comments/commentRss/326.aspx</wfw:commentRss>
            <trackback:ping>http://rickgaribay.net/services/trackbacks/326.aspx</trackback:ping>
        </item>
        <item>
            <title>Azure Service Bus Connect EAI and EDI &amp;ldquo;Integration Services&amp;rdquo; CTP</title>
            <link>http://rickgaribay.net/archive/2011/12/16/azure-service-bus-connect-eai-and-edi-ldquointegration-servicesrdquo-ctp.aspx</link>
            <description>&lt;p&gt;I am thrilled to share in the &lt;a href="http://blogs.msdn.com/b/windowsazure/archive/2011/12/16/announcing-the-service-bus-eai-amp-edi-labs-release.aspx" target="_blank"&gt;announcement&lt;/a&gt; that the first public CTP of Azure Service Bus Integration Services&lt;strong&gt; is now LIVE&lt;/strong&gt; at &lt;a href="http://portal.appfabriclabs.com"&gt;http://portal.appfabriclabs.com&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;The focus of this release is to enable you to build hybrid composite solutions that span on-premise investments such as Microsoft SQL Server, Oracle Database, SAP, Siebel eBusiness Applications, Oracle E-Business Suite, allowing you to compose these mission critical systems with applications, assets and workloads that you have deployed to Windows Azure, enabling first-class hybrid integration across traditional network and trust boundaries. &lt;/p&gt;  &lt;p&gt;In a web to web world, many of the frictions addressed in these capabilities still exist, albeit to a smaller degree. The reality is that as the web and cloud computing continue to gain momentum, investments on-premise are, and will continue to be critical to realizing the full spectrum of benefits that cloud computing provides both in the short and long term. &lt;/p&gt;  &lt;p&gt;So, what’s in this CTP?&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh689889.aspx" target="_blank"&gt;Azure Service Bus Connect&lt;/a&gt; provides a new server explorer experience for LOB integration exposing a management head that can be accessed on-prem via Server Explorer or PowerShell to create, update, delete or retrieve information from LOB targets. This provides a robust extension of the Azure Service Bus relay endpoint concept, which acts a LOB conduit (LobTarget, LobRelay) for bridging these assets by extending the WCF LOB Adapters that ship with BizTalk Server 2010. The beauty of this approach is that you can leverage the LOB Adapters using BizTalk as a host, or, for a lighter weight way approach, use IIS/Windows Server AppFabric to compose business operations on-premise and beyond. &lt;/p&gt;  &lt;p&gt;In addition, support for messaging between trading partners across traditional trust boundaries in business-to-business (B2B) scenarios using is EDI is also provided in this preview, including AS2 protocol support with X12 chaining for send and receive pipelines, FTP as transport for X12, agreement templates, partners view with profiles per partner, resources view, and an intuitive, metro style &lt;a href="http://i.msdn.microsoft.com/dynimg/IC553343.gif"&gt;EDI Portal&lt;img style="display: inline; float: right" title="Transforms Project Design Surface" alt="Transforms Project Design Surface" align="right" src="http://i.msdn.microsoft.com/dynimg/IC553343.gif" width="240" height="165" /&gt;&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Just as with on-premise integration, friction always exists when integrating different assets which may exist on different platforms, implement different standards and at a minimum have different representations of common entities that are part of your composite solution’s domain. What is needed is a mediation broker that can be leveraged at internet-scale, and apply message and protocol transformations across disparate parties and this is exactly what the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh689905.aspx" target="_blank"&gt;Transforms&lt;/a&gt; capability provides. Taking an approach that will be immediately familiar to the BizTalk developer, a familiar mapper-like experience is provided within Visual Studio for interactively mapping message elements and applying additional processing logic via operations (functoids).&lt;/p&gt;  &lt;p&gt;In addition, &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh689768.aspx" target="_blank"&gt;XML Bridges&lt;/a&gt; which include the XML One-Way Bridge and XML Request-Reply Bridge are an extension to the Azure Service Bus which supports critical patterns such as protocol bridging, routing actions, external data lookup for message enrichment and support for both WS-I and REST endpoints and any combination thereof.&lt;/p&gt;  &lt;p&gt;As shown below in the MSDN documentation, “bridges are composed of stages and activities where each stage is a message processing unit in itself. Each stage of a bridge is atomic, which means either a message completes a stage or not. A stage can be turned &lt;em&gt;on&lt;/em&gt; or &lt;em&gt;off&lt;/em&gt;, indicating whether to process a message or simply let it &lt;em&gt;pass through”&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;img style="margin: 0px 10px 0px 0px; display: inline; float: left" title="Stages of a bridge" alt="Stages of a bridge" align="left" src="http://i.msdn.microsoft.com/dynimg/IC551928.gif" /&gt;&lt;/p&gt;  &lt;p&gt;Taking a familiar VETR approach to validate, extract, transform and route messages from one party to another, along with the ability to enrich messages by composing other endpoint in-flight (supported protocols include HTTP, WS-HTTP and Basic HTTP, HTTP Relay Endpoint, Service Bus Queues/Topics and any other XML bridge) the Bridge is a very important capability and brings very robust capabilities for extending Azure Service Bus as a key messaging broker across integration disciplines. &lt;/p&gt;  &lt;p&gt;In reality, these patterns have no more to do with EAI than with traditional, contemporary service composition and become necessary once you move from a point-to-point approach and need to elegantly manage integration and composition across assets. As such, this capability acts as a bridge to Azure Service Bus that is very powerful in and of itself, even in non-EAI/EDI scenarios where endpoints can be virtualized increasing decoupling between parties (clients/services). In addition, this capability further enriches what is possible when using the BrokeredMessage property construct as a potential poor-man’s routing mechanism.   &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;In closing, the need to address the impedance mismatch that exists between disparate applications that must communicate with each other is a friction that will continue to exist for many years to come, and while traditionally, many of these problems have been solved by expensive, big iron middleware servers, this is changing. &lt;/p&gt;  &lt;p&gt;As with most technologies, often new possibilities are unlocked that are residual side-effects of something bigger, and this is certainly the case with how both &lt;a href="http://www.code-magazine.com/Article.aspx?quickid=1112041" target="_blank"&gt;innovative&lt;/a&gt; &lt;a href="http://www.code-magazine.com/Article.aspx?quickid=1112041" target="_blank"&gt;and strategic Azure Service Bus is to Microsoft’s PaaS strategy&lt;/a&gt;. Azure Service Bus continues to serve as a great example of a welcomed shift to a lightweight capability-based, platform-oriented approach to solving tough distributed messaging/integration problems while honoring the existing investments that organizations have made and benefiting from a common platform approach which is extremely unique in the market. And while this shift will take some time, in the long-run enterprises of all shapes and sizes only stand to benefit.&lt;/p&gt;  &lt;p&gt;To get started, download the SDK &amp;amp; samples from &lt;a href="http://go.microsoft.com/fwlink/?LinkID=184288"&gt;http://go.microsoft.com/fwlink/?LinkID=184288&lt;/a&gt; and the tutorial &amp;amp; documentation from &lt;a href="http://go.microsoft.com/fwlink/?LinkID=235197"&gt;http://go.microsoft.com/fwlink/?LinkID=235197&lt;/a&gt; and watch this and the &lt;a href="http://blogs.msdn.com/b/windowsazure/" target="_blank"&gt;Windows Azure&lt;/a&gt; blog for more details coming soon.&lt;/p&gt;  &lt;p&gt;Happy Messaging!&lt;/p&gt;&lt;img src="http://rickgaribay.net/aggbug/324.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rick G. Garibay</dc:creator>
            <guid>http://rickgaribay.net/archive/2011/12/16/azure-service-bus-connect-eai-and-edi-ldquointegration-servicesrdquo-ctp.aspx</guid>
            <pubDate>Fri, 16 Dec 2011 18:46:51 GMT</pubDate>
            <comments>http://rickgaribay.net/archive/2011/12/16/azure-service-bus-connect-eai-and-edi-ldquointegration-servicesrdquo-ctp.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://rickgaribay.net/comments/commentRss/324.aspx</wfw:commentRss>
            <trackback:ping>http://rickgaribay.net/services/trackbacks/324.aspx</trackback:ping>
        </item>
        <item>
            <title>Getting the Most out of WCF 4.0 REST Today</title>
            <link>http://rickgaribay.net/archive/2011/10/20/getting-the-most-out-of-wcf-4.0-rest-today-again.aspx</link>
            <description>&lt;p&gt;WCF has supported HTTP and RESTful approaches to service design for some time now, and while there are some exciting new enhancements being worked on as part of the &lt;a href="http://wcf.codeplex.com/" target="_blank"&gt;WCF Web API project&lt;/a&gt;, there is some pretty rich functionality in WCF 4.0 that is definitely worth taking advantage of if you need to build HTTP/REST services today, especially when hosting in Windows Server AppFabric. &lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/4187_04_25_4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="4187_04_25" border="0" alt="4187_04_25" align="right" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/4187_04_25_thumb_1.png" width="240" height="131" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;There a number of differences to consider when working with REST services that require some special attention as compared to traditional SOAP services, and those differences are definitely noticeable when working with WCF. In this post, I’d like to highlight some of the most common capabilities that REST developers ask for and how to accomplish them in general and when hosting in IIS or Windows Server AppFabric. The WCF Web API improves upon some of the techniques I cover here and introduces new ones which I’ll be discussing in future posts. &lt;/p&gt;  &lt;p&gt;The first thing you want to do when working with WCF REST is pick a project template. While WCF 4 supports REST out-of-the-box (including a number of improvements over previous versions and the alignment of out-of-band features first seen in the WCF Starter Kit), the default WCF templates are really designed for SOAP-based services and thus are rather lacking for supporting REST an an intuitive, F5 manner (again, this will get better). &lt;/p&gt;  &lt;p&gt;Microsoft provides the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd" target="_blank"&gt;WCF REST Service Application template&lt;/a&gt;  via the Visual Studio 2010 Extension Manager. In addition to some useful scaffolding for providing an F5 experience, some fundamental code and configuration is provided as part of the template which is necessary for working with a host such as IIS or Windows Server AppFabric. &lt;a href="http://twitter.com/ronljacobs" target="_blank"&gt;Ron Jacobs&lt;/a&gt; also has a great template specifically designed for Server AppFabric that extends the functionality in this template to support end to end monitoring and provides a web-based test harness among other things. I definitely recommend that you &lt;a href="http://visualstudiogallery.msdn.microsoft.com/a685f193-ed1e-4ad4-938f-f0bd8212d53d" target="_blank"&gt;check it out as well&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;To keep things focused on the basic aspects of WCF REST 4.0, I’ve taken the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd" target="_blank"&gt;WCF REST Service Application template&lt;/a&gt; with very minor modifications and created a simple read-only GET service to illustrate some of the most common things you’re likely to hit when starting out with REST in WCF 4. &lt;/p&gt;  &lt;p&gt;Out of the box, the WCF REST Service Application template provides some basic scaffolding including a functional read-only (GET) REST service. While “SampleItem” is certainly not the most interesting domain, I am going to leave the sample unaltered for simplicity sake as we are going to focus more on the hosting aspects of WCF REST than the design and the code.  &lt;/p&gt;  &lt;p&gt;Once you create a project with the WCF REST Service Application template, there are 4 files that are created in the project:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_16.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_thumb_7.png" width="192" height="175" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The Service1.cs file includes the definition and implementation of the service. &lt;/li&gt;    &lt;li&gt;The SampleItem.cs file includes the Data Contract that models a resource. &lt;/li&gt;    &lt;li&gt;The Global.asax file defines some key events that we’ll hook into to enable dynamic routing. &lt;/li&gt;    &lt;li&gt;The Web.config file includes some key configuration for enabling dynamic routing and supporting extension-less (svc-less) URIs among other things. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The first thing you’ll probably notice in the template is that its missing an .svc file. Most REST developers would rather work with clean URIs as opposed to having a file extension get in the way. Fortunately, with a little bit of help from ASP.NET, we can leverage some pretty sophisticated routing capabilities that not only allow us to eliminate the need for the .svc extension, but in addition enable us to factor our URIs across a number of services and have some pretty fine grained control over URI routes using a templated approach.&lt;/p&gt;  &lt;p&gt;If you hit F5 at this point, the service will run in Cassini, generating a rather glum response (note that you may not see XML immediately depending on the browser you are using; a brute force approach is to view source or, in the case of IE9, which I am using here, leverage the browser targeting capabilities provided by the F12 developer tools):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_18.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_thumb_8.png" width="1187" height="229" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;If you take a look inside the Global.asax.cs files, you’ll see what makes this magic happen:&lt;/p&gt;  &lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1: RouteTable.Routes.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ServiceRoute("Service1&lt;span style="color: #8b0000"&gt;&lt;/span&gt;", &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; WebServiceHostFactory(), &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(Service1)));
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2: &lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;As shown above, the template automatically added an entry to the System.Web.Routing.RouteTable. The Add method takes a ServiceRoute instance for which we provide 3 parameters:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The first parameter is known as a route prefix and signals the root path that will be mapped to a given WCF service type. In this case, the URI segment of “Service1” will route to the Service1 class as specified in the third parameter. &lt;/li&gt;

  &lt;li&gt;The second parameter is also interesting. Unlike traditional SOAP services that use a ServiceHost, the WebServiceHostFactory was designed to deal with HTTP-based services exclusively. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This default code can immediately be improved upon in my opinion by replacing the route prefix with a simple empty string. This will invoke the GetCollection method in the service implementation which provides a nice, intuitive user experience when interacting with the service without knowing much about it.&lt;/p&gt;

&lt;p&gt;Taking a look at the service class and the GetCollection method, you will see some familiar attributes, along with the AspNetCompatabilityRequirements attribute which, among other things enables support for routing:&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1:     [ServiceContract]
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:     [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:     [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4:     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Service1
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:     {
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  6:         [WebGet(UriTemplate = "&lt;span style="color: #8b0000"&gt;&lt;/span&gt;")]
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  7:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; List&amp;lt;SampleItem&amp;gt; GetCollection()
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  8:         {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  9:             &lt;span style="color: #008000"&gt;// TODO: Replace the current implementation to return a collection of SampleItem instances&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 10:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;SampleItem&amp;gt;() { &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SampleItem() { Id = 1, StringValue = "&lt;span style="color: #8b0000"&gt;Hello&lt;/span&gt;" } };
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 11:         }
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 12:     }&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;All of this also requires that ASP.NET compatibility is enabled declaratively in the Web.config by setting the aspNetCompatibilityEnabled attribute to true in the serviceHostingEnvironment element:&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1:  &amp;lt;system.serviceModel&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffff00; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:     &amp;lt;serviceHostingEnvironment aspNetCompatibilityEnabled="&lt;span style="color: #8b0000"&gt;true&lt;/span&gt;"/&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:     &amp;lt;standardEndpoints&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4:       &amp;lt;webHttpEndpoint&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:            &amp;lt;standardEndpoint name="&lt;span style="color: #8b0000"&gt;&lt;/span&gt;" helpEnabled="&lt;span style="color: #8b0000"&gt;true&lt;/span&gt;" automaticFormatSelectionEnabled="&lt;span style="color: #8b0000"&gt;true&lt;/span&gt;"/&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  6:       &amp;lt;/webHttpEndpoint&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  7:     &amp;lt;/standardEndpoints&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  8:   &amp;lt;/system.serviceModel&amp;gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;You will also notice that the web.config is absent of the boilerplate service and endpoint configuration including the address, binding and contract attributes. WCF 4 introduces the concept of default endpoints to simplify the approach for hosting services in WCF 4, which in effect automates the creation of common endpoint configurations for getting your WCF services up and running quickly and easily. Standard Endpoints build on this simplicity by providing common configurations packaged into an element and exercising convention over configuration. By using the WebHttpEndpoint standard endpoint, you are provided some common configuration knobs such as supporting multiple encoding types and help documentation that is automatically generated provided you enable the helpEnabled attribute in line 5 above:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_26.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_thumb_12.png" width="640" height="340" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While all of this works just fine in Cassini, it won’t work in IIS/Windows Server AppFabric as without the additional configuration I am going to cover next because it (rightfully) assumes that you are asking to browse the contents of the root directory which is fortunately forbidden unless you explicitly allow it:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_20.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_thumb_9.png" width="640" height="399" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that had I left the route prefix with the default “Service1”, a 404 would instead be thrown because without the correct modules, IIS has no way of routing this to the class by the same name.&lt;/p&gt;

&lt;p&gt;The remedy to these problems is provided by setting the runAllManagedModulesForAllRequests attribute in the modules element to true, which ensures that any requests that come into the request pipeline that are not mapped to an extension are passed on to the modules in the pipeline for processing. Specifically, the  route that was added to the Application_Start method implementation in the Global class will be used to resolve to the Service1 class by the UrlRoutingModule managed module which is registered using the configuration below and enables this routing for services that do not use the .svc extension and are hosted in IIS/Windows Server AppFabric: &lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1:  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.webServer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;modules&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runAllManagedModulesForAllRequests&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"true"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:       &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;add&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"UrlRoutingModule"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;type&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4:     &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;modules&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:   &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.webServer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;It is possible, depending on your IIS configuration that the UrlRoutingModule has already been registered, in which case line 3 above is superfluous. If you comment it out and re-deploy, things will continue to work as expected unless you either remove it declaratively in the web.config or explicitly remove it from the Modules manager.&lt;/p&gt;

&lt;p&gt;With this configuration in place, the service will result in the request being correctly routed and the response presented in the browser:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_22.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_thumb_10.png" width="640" height="397" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re like me, you likely find the XML, or at least the root node abhorrent. We can improve upon this significantly by creating a second class to represent the SampleItem that inherits from the original List&amp;lt;SampleItem&amp;gt; found in the template and decorate it with a CollectionDataContract attribute. &lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1:     [CollectionDataContract(Name = "&lt;span style="color: #8b0000"&gt;SampleItems&lt;/span&gt;",Namespace = "&lt;span style="color: #8b0000"&gt;&lt;/span&gt;")]
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SampleItems : List&amp;lt;SampleItem&amp;gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:     {
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:     }&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Further, if we override the Namespace by setting the Namespace parameter of the attribute and setting it to an empty string, we get a much nice, cleaner result:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_24.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_thumb_11.png" width="640" height="427" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="center"&gt;&lt;font size="1"&gt;Note: I have to credit this technique to &lt;a href="http://twitter.com/#!/jonflanders" target="_blank"&gt;Jon Flanders&lt;/a&gt;, who’s excellent book &lt;/font&gt;&lt;a href="http://www.amazon.com/RESTful-NET-Build-Consume-Services/dp/0596519206" target="_blank"&gt;&lt;font size="1"&gt;“Restful .NET”&lt;/font&gt;&lt;/a&gt;&lt;font size="1"&gt;  is where I first learned this technique a couple of years ago. &lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Some developers and administrators may be concerned about the potential performance implications that enabling the runAllManagedModulesForAllRequests attribute introduces for static requests such as HTML pages, image files, etc. since each of these requests must run through all of the configured modules unnecessarily. Fortunately, Microsoft introduced an alternative to this approach in a QFE Hotfix which enables dynamic routing without impacting static requests. You can download and install the Hotfix from here: http://support.microsoft.com/kb/980368. After installing the hotfix, three new handlers with a name prefix of ExtnesionlessUrlHandler are installed in IIS which correspond to 32, 64 bit and integrated modes and applied to all applications. With these handlers installed, you can remove or disable the runAllManagedModulesForAllRequests attribute and all routing will continue to function as expected provided the handlers remain registered as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/4187_04_31_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="4187_04_31" border="0" alt="4187_04_31" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/4187_04_31_thumb.png" width="640" height="357" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I was walking through the standard endpoint configuration, you may have noticed an attribute on the standard endpoint element called automaticFormattingEnabled. When set to true, this allows you to manipulate whether the service should return XML or JSON. According to MSDN, the determination is based on the following in order:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The media types in the request message’s Accept header. &lt;/li&gt;

  &lt;li&gt;The content-type of the request message. &lt;/li&gt;

  &lt;li&gt;The default format setting in the operation. &lt;/li&gt;

  &lt;li&gt;The default format setting in the WebHttpBehavior. 
    &lt;br /&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using Fiddler, I’ve set the Accept header to application/json which has the result of returning JSON without me having to do anything to the service itself:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_28.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/41cd8fc99175_1348A/image_thumb_13.png" width="640" height="367" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, you can have the service return plain text or a stream, but to do so today, you need to implement a custom mechanism for passing the format you need such as a querystring  and then writing some code to read it and return the appropriate expected format.&lt;/p&gt;

&lt;p&gt;Finally, one of the biggest benefits of designing REST services, or services that leverage the HTTP protocol exclusively, is that you get all of the features inherent to the HTTP protocol including support for caching requests, or GET requests. By adding an attribute called AspNetCacheProfile to the GetCollection method and mapping the profile name in the web.config, I can leverage the caching capabilities in ASP.NET to cache GET requests:&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1: [WebGet(UriTemplate = "&lt;span style="color: #8b0000"&gt;&lt;/span&gt;")]
&lt;/pre&gt;&lt;pre style="background-color: #ffff00; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2: [AspNetCacheProfile("&lt;span style="color: #8b0000"&gt;MyCacheProfile&lt;/span&gt;")]
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3: &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; SingleTracks GetCollection()
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4: {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; GetSingleTracks();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  6: }
&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;As I hope I’ve shown, there is pretty strong support for REST in WCF 4, both in the box and as provided by the WCF REST specific templates which allows you to easily host your WCF REST services on any host, including Windows Server AppFabric which allows you to take advantage of all of the great management and monitoring capabilities it provides. New features in the WCF Web API will make it even easier to host HTTP/REST services with WCF, so watch this space for some upcoming posts and be sure to keep up with the latest developments on the WCF Community Site at &lt;a title="http://wcf.codeplex.com/" href="http://wcf.codeplex.com/"&gt;http://wcf.codeplex.com/&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://rickgaribay.net/aggbug/319.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rick G. Garibay</dc:creator>
            <guid>http://rickgaribay.net/archive/2011/10/20/getting-the-most-out-of-wcf-4.0-rest-today-again.aspx</guid>
            <pubDate>Fri, 21 Oct 2011 06:09:10 GMT</pubDate>
            <comments>http://rickgaribay.net/archive/2011/10/20/getting-the-most-out-of-wcf-4.0-rest-today-again.aspx#feedback</comments>
            <wfw:commentRss>http://rickgaribay.net/comments/commentRss/319.aspx</wfw:commentRss>
            <trackback:ping>http://rickgaribay.net/services/trackbacks/319.aspx</trackback:ping>
        </item>
        <item>
            <title>Azure AppFabric Service Bus Brokered Messaging GA &amp;amp; Rude CTP Diffs</title>
            <link>http://rickgaribay.net/archive/2011/09/14/azure-appfabric-service-bus-brokered-messaging-ga-amp-rude-ctp.aspx</link>
            <description>&lt;p&gt;Today at the Build conference in Anaheim California, Satya Nadella, President Server and Tools business announced general availability of the production release of AppFabric Queues and Topics, otherwise known as Brokered Messaging.&lt;/p&gt;  &lt;p&gt;Brokered Messaging introduces durable queue capabilities and rich, durable pub-sub with topics and subscriptions that compliment the existing Relayed Messaging capabilities.  &lt;/p&gt;  &lt;p&gt;I covered Brokered Messaging following the &lt;a href="http://rickgaribay.net/archive/2011/05/17/appfabric-service-bus-v2-ctp.aspx" target="_blank"&gt;May CTP release&lt;/a&gt; of &lt;a href="http://rickgaribay.net/archive/2011/05/17/appfabric-service-bus-v2-ctp.aspx" target="_blank"&gt;Queues&lt;/a&gt; and followed up shortly with an overview and exploration of &lt;a href="http://rickgaribay.net/archive/2011/05/31/exploring-appfabric-service-bus-v2-may-ctp-topics.aspx" target="_blank"&gt;Topics&lt;/a&gt; (please see some other great resources at the end of this post).&lt;/p&gt;  &lt;p&gt;Since then, there was a June CTP release which included the new AppFabric Application and no visible changes to Brokered Messaging, however since its release, the AppFabric Messaging team has been hard at work refining the API and behaviors based on feedback from Advisors, MVPs and the community at large. &lt;/p&gt;  &lt;p&gt;Since I’ve already covered Queues and Topics in the aforementioned posts, I’ll dive right in to some terse examples which demonstrate the API changes. Though not an exhaustive review of all of the changes, I’ve covered the types that your most likely to come across and will cover Queues, Topics and Subscriptions extensively in my upcoming article in &lt;a href="http://www.code-magazine.com/SearchResults.aspx?search=garibay" target="_blank"&gt;CODE Magazine&lt;/a&gt; which will also include more in-depth walk-throughs of the .NET Client API, REST API and WCF scenarios.&lt;/p&gt;  &lt;p&gt;Those of you who have worked with the CTPs will find some subtle and not so subtle changes, but all in all I think all of the refinements are for the best and I think you’ll appreciate them as I have. For those new to Azure AppFabric Service Bus Brokered Messaging, you’ll benefit most from reading my first two posts based on the May CTP (or any of the resources at the end of this post) to get an idea of the why behind queues and topics and then come back here to explore the what and how.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;A Quick Note on Versioning&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In the CTPs that preceded the release of the new Azure AppFabric Service Bus features, a temporary assembly called “Microsoft.ServiceBus.Messaging.dll” was added to serve a container for new features and deltas that were introduced during the development cycle. The final release includes a single assembly called “Microsoft.ServiceBus.dll” which contains all of the existing relay capabilities that you’re already familiar with as well as the addition of support for queues and topics. If you are upgrading from the CTPs, you’ll want to get ahold of the new Microsoft.ServiceBus.dll version 1.5 which includes everything plus the new queue and topic features.&lt;/p&gt;  &lt;p&gt;The new 1.5 version of the Microsoft.ServiceBus.dll assembly targets the .NET 4.0 framework. Customers using .NET 3.5 can continue using the existing Microsoft.ServiceBus.dll  assembly (version 1.0.1123.2) for leveraging the relay capabilities, but must upgrade to .NET 4.0 to take advantage of the latest features presented here.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;.NET Client API&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;Queues&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="1072"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="251"&gt;&lt;strong&gt;May/June CTP&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="251"&gt;&lt;strong&gt;General Availability&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="568"&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;ServiceBusNamespaceClientSettings&lt;/td&gt;        &lt;td valign="top" width="251"&gt;NamespaceManagerSettings&lt;/td&gt;        &lt;td valign="top" width="568"&gt;New class for encapsulating endpoint and security settings.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;N/A&lt;/td&gt;        &lt;td valign="top" width="251"&gt;TokenProvider&lt;/td&gt;        &lt;td valign="top" width="568"&gt;New class for acquiring a WRAP token from ACS.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;ServiceBusNamespaceClient&lt;/td&gt;        &lt;td valign="top" width="251"&gt;NamespaceManager&lt;/td&gt;        &lt;td valign="top" width="568"&gt;Root management object for creating Queues, Topics, Subscriptions.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;Queue&lt;/td&gt;        &lt;td valign="top" width="251"&gt;QueueDescription&lt;/td&gt;        &lt;td valign="top" width="568"&gt;In May/June CTP, Topic / Queue / Subscription were management objects. All create/delete operations were moved to NamespaceManager and the state operations are now on TopicDescription/QueueDescription etc.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;MessagingFactorySettings&lt;/td&gt;        &lt;td valign="top" width="251"&gt;MessagingFactorySettings&lt;/td&gt;        &lt;td valign="top" width="568"&gt;New class for encapsulating security settings.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;MessagingFactory&lt;/td&gt;        &lt;td valign="top" width="251"&gt;MessagingFactory&lt;/td&gt;        &lt;td valign="top" width="568"&gt; &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;BrokeredMessage&lt;/td&gt;        &lt;td valign="top" width="251"&gt;BrokeredMessage&lt;/td&gt;        &lt;td valign="top" width="568"&gt;No longer a factory. Simply instantiate a BrokeredMessage.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;MessageSender&lt;/td&gt;        &lt;td valign="top" width="251"&gt;MessageSender&lt;/td&gt;        &lt;td valign="top" width="568"&gt;Optional, for use when you want to abstract away queue or topic.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="251"&gt;MessageReceiver&lt;/td&gt;        &lt;td valign="top" width="251"&gt;MessageReceiver&lt;/td&gt;        &lt;td valign="top" width="568"&gt;Optional, for use when you want to abstract away queue or topic.&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Below is a representative sample for creating, configuring, sending and receiving a message on a queue:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Administrative Operations&lt;/strong&gt;&lt;/p&gt;  &lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 817px; padding-right: 5px; height: 397px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:             &lt;span style="color: #008000"&gt;// Configure and create NamespaceManager for performing administrative operations&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:             NamespaceManagerSettings settings = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NamespaceManagerSettings();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4:             TokenProvider tokenProvider = settings.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuer,key);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:             
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  6:             NamespaceManager manager = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NamespaceManager(ServiceBusEnvironment.CreateServiceUri("&lt;span style="color: #8b0000"&gt;sb&lt;/span&gt;", serviceNamespace, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Empty), settings);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  7: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  8:             &lt;span style="color: #008000"&gt;// Check for existence of queues on the fabric&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  9:             var qs = manager.GetQueues();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 10: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 11:             var result = from q &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; qs
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 12:                          where q.Path.Equals(queueName, StringComparison.OrdinalIgnoreCase)
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 13:                          select q;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 14: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 15:             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (result.Count() == 0)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 16:             {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 17:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Queue does not exist&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 18: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 19:                 &lt;span style="color: #008000"&gt;// Create Queue&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 20:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Creating Queue...&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 21: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 22:                 manager.CreateQueue(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; QueueDescription(queueName) { LockDuration = TimeSpan.FromSeconds(5.0d) });
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 23:                 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 24:             }&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Runtime Operations&lt;/strong&gt;&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 815px; padding-right: 5px; height: 716px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1:             &lt;span style="color: #008000"&gt;// Create and Configure Messaging Factory to provision QueueClient&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:             MessagingFactorySettings messagingFactorySettings = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MessagingFactorySettings();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:             messagingFactorySettings.TokenProvider = settings.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuer, key);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4:             MessagingFactory messagingFactory = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("&lt;span style="color: #8b0000"&gt;sb&lt;/span&gt;", serviceNamespace, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Empty), messagingFactorySettings);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:             
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  6:             QueueClient queueClient = messagingFactory.CreateQueueClient(queueName, ReceiveMode.PeekLock);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  7: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  8:             Order order = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Order();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  9:             order.OrderId = 42;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 10:             order.Products.Add("&lt;span style="color: #8b0000"&gt;Kinect&lt;/span&gt;", 70.50M);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 11:             order.Products.Add("&lt;span style="color: #8b0000"&gt;XBOX 360&lt;/span&gt;", 199.99M);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 12:             order.Total = order.Products["&lt;span style="color: #8b0000"&gt;Kinect&lt;/span&gt;"] + order.Products["&lt;span style="color: #8b0000"&gt;XBOX 360&lt;/span&gt;"];
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 13: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 14:             &lt;span style="color: #008000"&gt;// Create a Brokered Message from the Order object&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 15:             BrokeredMessage msg = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BrokeredMessage(order);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 16: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 17:             &lt;span style="color: #008000"&gt;/***********************
&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 18:             *** Send Operations  ***
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 19:             ************************/
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 20: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 21:             queueClient.Send(msg);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 22: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 23:             &lt;span style="color: #008000"&gt;/**************************
&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 24:              *** Receive Operations ***
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 25:             ***************************/
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 26:             
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 27:             BrokeredMessage recdMsg;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 28:             Order recdOrder;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 29: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 30:             &lt;span style="color: #008000"&gt;// Receive and lock message&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 31:             recdMsg = queueClient.Receive();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 32: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 33:             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(recdMsg != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 34:             {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 35:                 &lt;span style="color: #008000"&gt;// Convert from BrokeredMessage to native Order&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 36:                 recdOrder = recdMsg.GetBody&amp;lt;Order&amp;gt;();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 37: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 38:                 Console.ForegroundColor = ConsoleColor.Green;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 39:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Received Order {0} \n\t with Message Id {1} \n\t and Lock Token:{2} \n\t from {3} \n\t with total of ${4}&lt;/span&gt;", recdOrder.OrderId, recdMsg.MessageId, recdMsg.LockToken, "&lt;span style="color: #8b0000"&gt;Receiver 1&lt;/span&gt;", recdOrder.Total);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 40:                 recdMsg.Complete();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 41:             }
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 42:             queueClient.Close();&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Note that MessageSender and MessageReceiver are now optional. Here’s an example that shows PeekLocking a message, simulating an exception and trying again:&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 828px; padding-right: 5px; height: 533px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:             &lt;span style="color: #008000"&gt;// Alternate receive approach using agnostic MessageReceiver&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:             MessageReceiver receiver = messagingFactory.CreateMessageReceiver(queueName);            &lt;span style="color: #008000"&gt;// Recieve, complete, and delete message from the fabric&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:             &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  6:             {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  7:                 &lt;span style="color: #008000"&gt;// Receive and lock message&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  8:                 recdMsg = receiver.Receive();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  9: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 10:                 &lt;span style="color: #008000"&gt;// Convert from BrokeredMessage to native Order&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 11:                 recdOrder = recdMsg.GetBody&amp;lt;Order&amp;gt;();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 12: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 13:                 &lt;span style="color: #008000"&gt;// Complete read, release and delete message from the fabric&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 14:                 receiver.Complete(recdMsg.LockToken);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 15: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 16:                 Console.ForegroundColor = ConsoleColor.Green;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 17:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Received Order {0} \n\t with Message Id {1} \n\t and Lock Token:{2} \n\t from {3} \n\t with total of ${4} \n\t at {5}&lt;/span&gt;", recdOrder.OrderId, recdMsg.MessageId, recdMsg.LockToken, "&lt;span style="color: #8b0000"&gt;Receiver 2&lt;/span&gt;", recdOrder.Total, DateTime.Now.Hour + "&lt;span style="color: #8b0000"&gt;:&lt;/span&gt;" + DateTime.Now.Minute + "&lt;span style="color: #8b0000"&gt;:&lt;/span&gt;" + DateTime.Now.Second);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 18:             }
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 19:             &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 20:             {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 21:                 &lt;span style="color: #008000"&gt;// Should processing fail, release the lock from the fabric and make message available for later processing.&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 22:                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (recdMsg != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 23:                 {
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 24:                     receiver.Abandon(recdMsg.LockToken);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 25:                     
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 26:                     Console.ForegroundColor = ConsoleColor.Red;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 27:                     Console.WriteLine("&lt;span style="color: #8b0000"&gt;Message could not be processed.&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 28: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 29:                 }
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 30:             }
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 31:             &lt;span style="color: #0000ff"&gt;finally&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 32:             {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 33:                 receiver.Close();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 34:             }&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As shown below, this sample results in order 42 being received by the QueueClient:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/AppFabric-Service-Bus-Queues--Topics-Rel_D1C0/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/AppFabric-Service-Bus-Queues--Topics-Rel_D1C0/image_thumb.png" width="807" height="127" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;br /&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;Topics&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;table border="1" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;&lt;b&gt;May/June CTP&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;&lt;b&gt;General Availability&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt;
        &lt;p&gt;&lt;b&gt;Comments&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;Topic&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;TopicDescription&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt;
        &lt;p&gt;In May/June CTP, Topic / Queue / Subscription were management objects. All create/delete operations were moved to NamespaceManager and the state operations are now on TopicDescription/QueueDescription etc.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;TopicClient&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;TopicClient&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt;
        &lt;p&gt;As noted in the Queues section, you can use TopicClient or MessageSender in the event you want to abstract details of using Topics.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;SubscriptionClient&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;SubscriptionClient&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt;
        &lt;p&gt;As noted in the Queues section, you can use SubscriptionClient or MessageReceiver in the event you want to abstract details of using a Topic/Subscription.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;Subscription&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;SubscriptionDescription&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt;Changes to constructors and use of properties (see code samples below), but intent is the same.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;RuleDescription&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;RuleDescription&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt;Changes to constructors and use of properties (see code samples below), but intent is the same.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;FilterExpression&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;Filter&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt;
        &lt;p&gt;Base for Filter types such as SqlFilter&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;SqlFilterExpression&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;SqlFilter&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt; &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="268"&gt;
        &lt;p&gt;FilterAction&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="239"&gt;
        &lt;p&gt;RuleAction&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="566"&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Below is a representative sample for creating, configuring, sending and receiving a message on a topic:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Administrative Operations&lt;/strong&gt;&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 836px; padding-right: 5px; height: 632px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1:             &lt;span style="color: #008000"&gt;// Configure and create NamespaceManager for performing administrative operations&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:             NamespaceManagerSettings settings = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NamespaceManagerSettings();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:             settings.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuer, key);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4:             NamespaceManager manager = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NamespaceManager(ServiceBusEnvironment.CreateServiceUri("&lt;span style="color: #8b0000"&gt;sb&lt;/span&gt;", serviceNamespace, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Empty), settings);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  6:             &lt;span style="color: #008000"&gt;// Check for existence of topics on the fabric&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  7:             var topics = manager.GetTopics();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  8: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  9:             var result = from t &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; topics
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 10:                          where t.Path.Equals(topicName, StringComparison.OrdinalIgnoreCase)
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 11:                          select t;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 12: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 13:             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (result.Count() == 0)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 14:             {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 15:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Topic does not exist&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 16: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 17:                 &lt;span style="color: #008000"&gt;// Create Queue&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 18:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Creating Topic...&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 19: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 20:                 TopicDescription topic = manager.CreateTopic(topicName);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 21:             }
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 22: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 23:             &lt;span style="color: #008000"&gt;// Create Subscriptions for InventoryServiceSubscription and CreditServiceSubscription and associate to OrdersTopic:&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 24:             SubscriptionDescription inventoryServiceSubscription = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SubscriptionDescription(topicName, "&lt;span style="color: #8b0000"&gt;InventoryServiceSubscription&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 25:             SubscriptionDescription creditServiceSubscription = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SubscriptionDescription(topicName, "&lt;span style="color: #8b0000"&gt;CreditServiceSubscription&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 26: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 27: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 28:             &lt;span style="color: #008000"&gt;// Set up Filters for NorthAmericaFulfillmentServiceSubscription&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 29:             RuleDescription northAmericafulfillmentRuleDescription = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RuleDescription();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 30:             northAmericafulfillmentRuleDescription.Filter = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlFilter("&lt;span style="color: #8b0000"&gt;CountryOfOrigin = 'USA' OR CountryOfOrigin ='Canada' OR CountryOfOrgin ='Mexico'&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 31:             northAmericafulfillmentRuleDescription.Action = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlRuleAction("&lt;span style="color: #8b0000"&gt;set FulfillmentRegion='North America'&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 32: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 33: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 34:             &lt;span style="color: #008000"&gt;// Create Subscriptions&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 35:             SubscriptionDescription northAmericaFulfillmentServiceSubscription = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SubscriptionDescription(topicName, "&lt;span style="color: #8b0000"&gt;NorthAmericaFulfillmentServiceSubscription&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 36: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 37:             &lt;span style="color: #008000"&gt;// Delete existing subscriptions&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 38:             &lt;span style="color: #0000ff"&gt;try&lt;/span&gt; { manager.DeleteSubscription(topicName, inventoryServiceSubscription.Name); } &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; { };
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 39:             &lt;span style="color: #0000ff"&gt;try&lt;/span&gt; { manager.DeleteSubscription(topicName, creditServiceSubscription.Name); } &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; { };
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 40:             &lt;span style="color: #0000ff"&gt;try&lt;/span&gt; { manager.DeleteSubscription(topicName, northAmericaFulfillmentServiceSubscription.Name); } &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; { };
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 41: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 42:             
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 43:             &lt;span style="color: #008000"&gt;// Add Subscriptions and Rules to Topic&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 44:             manager.CreateSubscription(inventoryServiceSubscription);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 45:             manager.CreateSubscription(creditServiceSubscription);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 46:             manager.CreateSubscription(northAmericaFulfillmentServiceSubscription, northAmericafulfillmentRuleDescription);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 47:             &lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Runtime Operations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 842px; padding-right: 5px; height: 631px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  1:             &lt;span style="color: #008000"&gt;// Create and Configure Messaging Factory to provision TopicClient&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  2:             MessagingFactorySettings runtimeSettings = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MessagingFactorySettings();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  3:             runtimeSettings.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuer, key);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  4:             MessagingFactory messagingFactory = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("&lt;span style="color: #8b0000"&gt;sb&lt;/span&gt;",serviceNamespace,String.Empty),runtimeSettings);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  5:             
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  6:             &lt;span style="color: #008000"&gt;// Create Topic Client for sending messages to the Topic:&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  7:             TopicClient client = messagingFactory.CreateTopicClient(topicName);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  8:          
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;  9:             &lt;span style="color: #008000"&gt;/***********************
&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 10:              *** Send Operations ***
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 11:              ***********************/
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 12: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 13:             &lt;span style="color: #008000"&gt;// Prepare BrokeredMessage and corresponding properties&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 14:             Order order = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Order();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 15:             order.OrderId = 42;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 16:             order.Products.Add("&lt;span style="color: #8b0000"&gt;Kinect&lt;/span&gt;", 70.50M);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 17:             order.Products.Add("&lt;span style="color: #8b0000"&gt;XBOX 360&lt;/span&gt;", 199.99M);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 18:             order.Total = order.Products["&lt;span style="color: #8b0000"&gt;Kinect&lt;/span&gt;"] + order.Products["&lt;span style="color: #8b0000"&gt;XBOX 360&lt;/span&gt;"];
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 19: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 20:             &lt;span style="color: #008000"&gt;// Set the body to the Order data contract&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 21:             BrokeredMessage msg = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BrokeredMessage(order);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 22:             
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 23:             &lt;span style="color: #008000"&gt;// Set properties for use in RuleDescription&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 24:             msg.Properties.Add("&lt;span style="color: #8b0000"&gt;CountryOfOrigin&lt;/span&gt;", "&lt;span style="color: #8b0000"&gt;USA&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 25:             msg.Properties.Add("&lt;span style="color: #8b0000"&gt;FulfillmentRegion&lt;/span&gt;", "&lt;span style="color: #8b0000"&gt;&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 26:             
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 27:             &lt;span style="color: #008000"&gt;// Send the message to the OrdersTopic&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 28:             client.Send(msg);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 29:             client.Close();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 30:             
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 31:            &lt;span style="color: #008000"&gt;/**************************
&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 32:              *** Receive Operations ***
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 33:            ****************************/
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 34:         
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 35:             BrokeredMessage recdMsg;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 36:             Order recdOrder;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 37: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 38:             &lt;span style="color: #008000"&gt;// Inventory Service Subscriber&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 39:             SubscriptionClient inventoryServiceSubscriber = messagingFactory.CreateSubscriptionClient(topicName, "&lt;span style="color: #8b0000"&gt;InventoryServiceSubscription&lt;/span&gt;",ReceiveMode.PeekLock);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 40:             
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 41:             &lt;span style="color: #008000"&gt;// Read the message from the OrdersTopic&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 42:             &lt;span style="color: #0000ff"&gt;while&lt;/span&gt; ((recdMsg = inventoryServiceSubscriber.Receive(TimeSpan.FromSeconds(5))) != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 43:             {   
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 44:                 &lt;span style="color: #008000"&gt;// Convert from BrokeredMessage to native Order&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 45:                 recdOrder = recdMsg.GetBody&amp;lt;Order&amp;gt;();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 46: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 47:                 &lt;span style="color: #008000"&gt;// Complete read, release and delete message from the fabric&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 48:                 inventoryServiceSubscriber.Complete(recdMsg.LockToken);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 49: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 50:                 Console.ForegroundColor = ConsoleColor.Green;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 51:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Received Order {0} \n\t on {1} \n\t with Message Id {2} \n\t and Lock Token {3}.&lt;/span&gt;", recdOrder.OrderId, "&lt;span style="color: #8b0000"&gt;Inventory Service Subscriber&lt;/span&gt;", recdMsg.MessageId, recdMsg.LockToken);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 52:             }
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 53:             inventoryServiceSubscriber.Close();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 54: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 55:             &lt;span style="color: #008000"&gt;// Credit Service Subscriber&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 56:             SubscriptionClient creditServiceSubscriber = messagingFactory.CreateSubscriptionClient(topicName, "&lt;span style="color: #8b0000"&gt;CreditServiceSubscription&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 57: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 58:             &lt;span style="color: #008000"&gt;// Read the message from the OrdersTopic&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 59:             recdMsg = creditServiceSubscriber.Receive();
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 60: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 61:             &lt;span style="color: #008000"&gt;// Convert from BrokeredMessage to native Order&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 62:             recdOrder = recdMsg.GetBody&amp;lt;Order&amp;gt;();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 63: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 64:             &lt;span style="color: #008000"&gt;// Complete read, release and delete message from the fabric&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 65:             creditServiceSubscriber.Complete(recdMsg.LockToken);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 66: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 67:             Console.ForegroundColor = ConsoleColor.Green;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 68:             Console.WriteLine("&lt;span style="color: #8b0000"&gt;Received Order {0} \n\t on {1} \n\t with Message Id {2} \n\t and Lock Token {3}.&lt;/span&gt;", recdOrder.OrderId, "&lt;span style="color: #8b0000"&gt;Credit Service Subscriber&lt;/span&gt;", recdMsg.MessageId, recdMsg.LockToken);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 69: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 70:             creditServiceSubscriber.Close();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 71: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 72:             &lt;span style="color: #008000"&gt;// Fulfillment Service Subscriber for the North America Fulfillment Service Subscription&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 73:             SubscriptionClient northAmericaFulfillmentServiceSubscriber = messagingFactory.CreateSubscriptionClient(topicName, "&lt;span style="color: #8b0000"&gt;northAmericaFulfillmentServiceSubscription&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 74:             
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 75:             &lt;span style="color: #008000"&gt;// Read the message from the OrdersTopic for the North America Fulfillment Service Subscription&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 76:             recdMsg = northAmericaFulfillmentServiceSubscriber.Receive(TimeSpan.FromSeconds(5));
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 77: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 78:             
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 79:            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(recdMsg != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 80:             {
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 81:                 &lt;span style="color: #008000"&gt;// Convert from BrokeredMessage to native Order&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 82:                 recdOrder = recdMsg.GetBody&amp;lt;Order&amp;gt;();
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 83: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 84:                 &lt;span style="color: #008000"&gt;// Complete read, release and delete message from the fabric&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 85:                 northAmericaFulfillmentServiceSubscriber.Complete(recdMsg.LockToken);
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 86: 
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 87:                 Console.ForegroundColor = ConsoleColor.Green;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 88:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;Received Order {0} \n\t on {1} \n\t with Message Id {2} \n\t and Lock Token {3}.&lt;/span&gt;", recdOrder.OrderId, "&lt;span style="color: #8b0000"&gt;North America Fulfillment Service Subscriber&lt;/span&gt;", recdMsg.MessageId, recdMsg.LockToken);
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 89:             }
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 90:             &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 91:             {
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 92:                 Console.ForegroundColor = ConsoleColor.Yellow;
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 93:                 Console.WriteLine("&lt;span style="color: #8b0000"&gt;No messages for North America found.&lt;/span&gt;");
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 94:             }
&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 95:             
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt; 96:             northAmericaFulfillmentServiceSubscriber.Close();&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When running this sample, you’ll see that I have received Order 42 on my Inventory, Credit and North America Fulfillment Service subscriptions:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/AppFabric-Service-Bus-Queues--Topics-Rel_D1C0/image_6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 2px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/Windows-Live-Writer/AppFabric-Service-Bus-Queues--Topics-Rel_D1C0/image_thumb_2.png" width="802" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;WCF&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the great things about the WCF programming model is that it abstracts much of the underlying communication details and as such, other than dropping in a new assembly and and refactoring the binding and configuration, it is not greatly affected by the API changes from the May/June CTP to GA.&lt;/p&gt;

&lt;p&gt;As I mentioned, one thing that has changed is that the ServiceBusMessagingBinding has been renamed to NetMessagingBinding. I’ll be covering and end to end example of using the NetMessagingBinding in my upcoming article in &lt;a href="http://www.code-magazine.com/SearchResults.aspx?search=garibay" target="_blank"&gt;CODE Magazine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;REST API&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The REST API is key to delivering these new capabilities across a variety of client platforms and remains largely unchanged, however one key change is how message properties are handled. Instead of individual headers for each, there is now one header with  all the properties JSON encoded. Please refer to the updated REST API Reference doc for details. I’ll also be covering and end-to-end example of using the REST API to write an read to/from a queue in my upcoming article in &lt;a href="http://www.code-magazine.com/SearchResults.aspx?search=garibay" target="_blank"&gt;CODE Magazine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;More Coming Soon&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As I mentioned, in my upcoming article in &lt;a href="http://www.code-magazine.com/SearchResults.aspx?search=garibay" target="_blank"&gt;CODE Magazine&lt;/a&gt;, I’ll cover the Why, What, and How behind Azure AppFabric Service Bus Brokered Messaging including end to end walkthroughs with the .NET Client API, REST API and WCF Binding. The November/December issue should be on newsstands (including Barnes and Noble) or your mailbox towards the end of October. You can also find the article online at &lt;a href="http://code-magazine.com"&gt;http://code-magazine.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;Resources&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can learn more about this exciting release as well as download the GA SDK version 1.5 by visiting the following resources:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Azure AppFabric SDK 1.5:&lt;a title="http://www.microsoft.com/download/en/details.aspx?id=27421" href="http://www.microsoft.com/download/en/details.aspx?id=27421"&gt;http://www.microsoft.com/download/en/details.aspx?id=27421&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://twitter.com/clemensv" target="_blank"&gt;Clemens Vasters&lt;/a&gt; on the May CTP: &lt;a title="http://vasters.com/clemensv/2011/05/16/Introducing+The+Windows+Azure+AppFabric+Service+Bus+May+2011+CTP.aspx" href="http://vasters.com/clemensv/2011/05/16/Introducing+The+Windows+Azure+AppFabric+Service+Bus+May+2011+CTP.aspx"&gt;http://vasters.com/clemensv/2011/05/16/Introducing+The+Windows+Azure+AppFabric+Service+Bus+May+2011+CTP.aspx&lt;/a&gt;  &lt;/li&gt;

  &lt;li&gt;Great video by &lt;a href="http://twitter.com/clemensv" target="_blank"&gt;Clemens Vasters&lt;/a&gt; on Brokered Messaging: &lt;a title="http://vasters.com/clemensv/2011/06/11/Understanding+Windows+Azure+AppFabric+Queues+And+Topics.aspx" href="http://vasters.com/clemensv/2011/06/11/Understanding+Windows+Azure+AppFabric+Queues+And+Topics.aspx"&gt;http://vasters.com/clemensv/2011/06/11/Understanding+Windows+Azure+AppFabric+Queues+And+Topics.aspx&lt;/a&gt;  &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://twitter.com/#!/dingha" target="_blank"&gt;David Ingham&lt;/a&gt; on Queues: &lt;a title="http://blogs.msdn.com//b/appfabric/archive/2011/05/17/an-introduction-to-service-bus-queues.aspx" href="http://blogs.msdn.com//b/appfabric/archive/2011/05/17/an-introduction-to-service-bus-queues.aspx"&gt;http://blogs.msdn.com//b/appfabric/archive/2011/05/17/an-introduction-to-service-bus-queues.aspx&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://twitter.com/#!/dingha" target="_blank"&gt;David Ingham&lt;/a&gt; on Topics: &lt;a title="http://blogs.msdn.com//b/appfabric/archive/2011/05/25/an-introduction-to-service-bus-topics.aspx" href="http://blogs.msdn.com//b/appfabric/archive/2011/05/25/an-introduction-to-service-bus-topics.aspx"&gt;http://blogs.msdn.com//b/appfabric/archive/2011/05/25/an-introduction-to-service-bus-topics.aspx&lt;/a&gt;  &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://twitter.com/rickggaribay" target="_blank"&gt;My&lt;/a&gt; Introduction to Queues: &lt;a title="http://rickgaribay.net/archive/2011/05/17/appfabric-service-bus-v2-ctp.aspx" href="http://rickgaribay.net/archive/2011/05/17/appfabric-service-bus-v2-ctp.aspx"&gt;http://rickgaribay.net/archive/2011/05/17/appfabric-service-bus-v2-ctp.aspx&lt;/a&gt;  &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://twitter.com/rickggaribay" target="_blank"&gt;My&lt;/a&gt; Introduction to Topics:&lt;a title="http://rickgaribay.net/archive/2011/05/31/exploring-appfabric-service-bus-v2-may-ctp-topics.aspx" href="http://rickgaribay.net/archive/2011/05/31/exploring-appfabric-service-bus-v2-may-ctp-topics.aspx"&gt;http://rickgaribay.net/archive/2011/05/31/exploring-appfabric-service-bus-v2-may-ctp-topics.aspx&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://rickgaribay.net/aggbug/315.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rick G. Garibay</dc:creator>
            <guid>http://rickgaribay.net/archive/2011/09/14/azure-appfabric-service-bus-brokered-messaging-ga-amp-rude-ctp.aspx</guid>
            <pubDate>Wed, 14 Sep 2011 16:46:52 GMT</pubDate>
            <comments>http://rickgaribay.net/archive/2011/09/14/azure-appfabric-service-bus-brokered-messaging-ga-amp-rude-ctp.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://rickgaribay.net/comments/commentRss/315.aspx</wfw:commentRss>
            <trackback:ping>http://rickgaribay.net/services/trackbacks/315.aspx</trackback:ping>
        </item>
        <item>
            <title>A Middle-Tier Guy&amp;rsquo;s Take on HTML 5</title>
            <link>http://rickgaribay.net/archive/2011/08/22/a-middle-tier-guyrsquos-take-on-html-5.aspx</link>
            <description>&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;(My) Early Beginnings&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I started my career in software development as a very junior web developer in 1999. I taught myself HTML, VBScript and JavaScript. The browser wars between Microsoft and Netscape were raging. I still remember how exciting my first Classic ASP page was. The fact that I was able to connect to an Access or SQL Server 7 database with just a few lines of code inside my markup was incredible at the time. I consumed new recipes from “4 Guys from Rolla” with relish and kept Scott Mitchell’s titles like “Teach Yourself Classic ASP 3.0 in 21 Days” on my desk at all times (it’s still on my bookshelf which itself has become a sort of Smithsonian for software development over the last decade). Even more exciting was that fact that it seemed like the beginning of a new era in which I could relegate JavaScript as a necessary evil for handling tricks like focus and validation on the UI. &lt;/p&gt;  &lt;p&gt;At the time, I was doing some really fun and interesting work as a young Padawan for the credit card division inside the #1 Visa issuer in the country (we didn’t have a fancy name for it other than “reports” back then but we were doing very early work on what would become “BI”). By rendering data-driven operational reports dynamically on the browser, we had revolutionized how metrics like Occupancy, Average Handle Time, and Multiple-Call-Rate were disseminated within the bank ushering in a new era of productivity, transparency and accountability for everyone from agent to VP. Through this experience, we built a center of excellence which served as a benchmark for other call centers to follow (in fact, we had the likes of Amex come in and review how we did it). Sure, we had displaced an army of Excel Macro and Access developers, but such was the price of progress.  As this little rogue IT shop basking in our success, I remember a number of “true programmer” personas in the “Real IT” group that tended to undermine what was happening. These were programmers who came from C++ or Java (and whose managers felt threatened by what we were able to do with such few resources) and mostly thumbed their nose at things like lack of strong typing, OO, etc. They looked at JavaScript as just a tool for dirty hippie web masters (remember that term) and VBScript as as something OK for administrators to use to walk AD hives, but being inferior for lacking OO and being handicapped by things like variants. Despite our incredibly visible success (at the CEO level and above) by applying these scripting technologies, I was hungry to see the forest for the trees and experimented a bit with COM and COM+, learning how to encapsulate business logic in components and delighting in being able to wire up my COM libraries with Classic ASP even though with the exception of my manager and mentor at the time, no one else even had the tools to debug my components. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Server Era&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Then, this thing called Windows DNA came along which promised to marry Windows, ActiveX and Internet into one big cluster… well you know. Fortunately, it’s fate was short-lived, but I remember attending a couple MSDN events where it seemed like concurrency and single threaded apartments would become mainstream topics on the web. Maybe us script kiddies would earn some respect after all? Then, just like that, this new, new thing called .NET happened. All of a sudden, just like that, I had a ton to learn. All my Classic ASP and JavaScript skills were superseded by Web Forms. I still remember stepping through every line of code in the I Buy Spy reference app and being completely blow away. ASP.NET offered something that was OO, strongly typed, and would even render JavaScript for you. Cumbersome JavaScript validation was replaced by server-side templates and controls. Form fields magically remembered their values across post backs. And, as I learned, WebForms offered a better separation of concerns with a nice, clean code-behind model that I would later leverage to introduce patterns like MVP, MVC Page Controller and Front Controller. I built a nice CMS portal for a multi-national bank (which according to Forbes Magazine is the largest public trading company in the world today) with these new skills and I hear it is still running today. Life was good. This was the age of the web server, and the only major argument within the Microsoft web community at that time was “C# or VB.NET”? &lt;/p&gt;  &lt;p&gt;At this point in my career, I’d grown a bit bored with web development. I felt like I’d accomplished everything I wanted to with ASP.NET, and the roles I found myself in started dealing with problems at a more holistic, program level which would involve a handful of web apps and coordination between them and new and existing enterprise resources. I discovered Web Services, and the problems I was now trying to solve led to the gradual gravitation to enterprise architecture and middleware and before I knew it, I was hooked. Admittedly, it was a great time to make the shift. SOA was king. COM+ had grown up with support for Enterprise Services in .NET and in parallel, this amazing new messaging framework codenamed “Indigo” was in development that would provide a black belt for hungry ninjas like me who wanted to take over the world with SOA. When it came to Indigo, there were two types of members in the community: Those on this inside, and the rest of the world. I was very much part of the rest of the world, but I consumed every bit of content I could get my hands on from folks like Don Box, Juval Lowy, Wenlong Dong, Michele Bustamante and Dr. Nick. &lt;/p&gt;  &lt;p&gt;Around the same time, a major re-engineering of a product called BizTalk Server was nearing release which took full advantage of the .NET Framework. My employer then, a mid-sized auto retail and finance company was one of the first BizTalk Server 2004 customers in Phoenix. For a fledging enterprise integration architect, this was an awesome opportunity. I learned a ton from my friend Todd Sussman, Brian Loesgen and Adam Smith, the latter of the two I wouldn’t meet in person for a few years, but I had read “BizTalk Server 2004 Unleashed” and “The Blogger’s Guide to BizTalk” from cover to cover more than once. Even better was that I was leading the development of our first SOA and 802.11 enterprise mobility project. We had decided to build the mobile apps- which were a superset of a desktop control center- with ASP.NET. Users would hit the same URL whether they were on the desktop or in the field with their device, and the right screen would render. All of our business logic was wrapped in an ASMX façade which then communicated with our BizTalk orchestrations. With my first real enterprise program under my belt, and WCF nearing GA, I decided that this was what I wanted to do when I grew up, or at least for the next 5 years. &lt;/p&gt;  &lt;p&gt;Along with WCF, WPF was nearing release. WPF offered a completely different paradigm on which to build traditional Windows apps. Support for rich media like video and sound, flat controls, new gradients all with an incredibly “webby” DHTML-looking design aesthetic. At the time, I remember introspecting that if presentation technologies like this were successful at winning over users, then one day, users won’t care if they are using a browser or an OS to interact with software. What I didn’t realize was to what extent &lt;em&gt;&lt;strong&gt;everyone’s&lt;/strong&gt;&lt;/em&gt; cheese was about to be moved. Here we had two tremendously powerful additions to the .NET Framework, poised to revolutionize how we write software from a presentation and back-end perspective, and yet, something subtle was happening that was bigger than Microsoft, bigger than the marvel that is .NET.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Web Reborn&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Content building SOA solutions in the walled gardens of my employers and clients, almost overnight, I remember when web developers started insisting on me starting to expose JSON endpoints on my services. Apparently, while I was in messaging la la land, users had grown tired of refreshing their browsers and posting back to the server every time they submitted a form. Turns out, I too was one of them! Users were demanding not just a dynamic web experience, but one that was interactive, and felt more like a rich client (a great example at this time was Outlook Web Access). But if you wanted a rich experience, isn’t that why you stuck to the desktop and used WPF? Following the promulgation of XML as the second coming, wasn’t JSON nothing more than an esoteric relic of JavaScript? AJAX had arrived. What followed was a complete disruption of the seeming balance between intended purpose that would shift the pendulum once again to the web. &lt;/p&gt;  &lt;p&gt;This was about the same time that Microsoft had shared its vision for Software + Services, first unveiled at Mix 07. On the outside, the Mix conference was all about the web, but the reality was that this was also part of a pretty massive campaign to court and win over designers from Adobe/Macromedia to a new technology: WPF/Everywhere, aka Silverlight. While many had been signaling WPF as the return of the smart client, users were accepting an alternate, even degraded user experience in exchange for interop. Silverlight offered a superset of WPF capabilities, delivering a somewhat equally productive design time and development experience as .NET and thus began penetrating Apple and Linux via the ubiquity of the browser. This was the first time I saw Microsoft really understanding that it wasn’t only about .NET and Windows anymore. This was evidenced by prominent PMs on stage demonstrating Silverlight apps on Macs, and running Linux distros on VMs to show that you could write the app once, and run it (almost) everywhere. A number of incredible apps were released on Silverlight including examples like Netflix and Hard Rock Café Memorabilia which were each both a sign of the times and a hint at what was to come.&lt;/p&gt;  &lt;p&gt;To be sure, this had indeed become a software + services world, and for a while Silverlight looked promising despite the tremendous market footprint that Flash had and continues to have. I remember &lt;a href="http://rickgaribay.net/archive/2007/04/30/Let-There-Be-Silverlight.aspx" target="_blank"&gt;writing&lt;/a&gt; about how remarkable Silverlight was and what a game changer it could be. But then, an interesting thing happened. JavaScript and REST started appearing more and more in web apps, particularly in the consumer space. At first, despite the popularity of Fielding’s paper, REST seemed like a fringe thing, and in many ways a step backward. Here we had a tremendously powerful consortium of standards built around SOAP representing the intersection of the very few things big players like Microsoft, IBM, Sun and Oracle agreed on. What’s more, it seemed that Microsoft had timed this SOAP bubble (no pun intended) perfectly, with its shiny, new, equally efficacious messaging stack called WCF which was, and still today remains unrivaled by other platform vendors. In addition to HTTP, WCF brought TCP, MSMQ and IPC to the enterprise, offering (proprietary) binary encoding and MTOM for optimizing message exchanges. The programming model had (and continues to have) a learning curve over ASMX, but once you got over the hump, you were on a high summit and could see the world for miles around from this new vantage point. So, why in the world would anyone want to go back to using HTTP POST and POX? How could it be that the world was settling for REST and JavaScript? &lt;/p&gt;  &lt;p&gt;Simple. The world (and the internet) was changing. A gradual, yet viral shift was taking place fueled by the success of Ruby on Rails and PHP which built the foundation for what is today known as Web 2.0. All of a sudden, anyone with a laptop and an internet connection could download a few packages and get an app up and running in no time. The barrier to entry was financially negligible and because these languages fully embraced HTTP, a tremendous community was born that was as smart as they were entrepreneurial. Interop and reuse were mere side-effects that led to tremendous adoption by everyone with a browser. Fully embracing JavaScript with their productivity boosting libraries that took the sting out of writing JavaScript, similar approaches to packaging robust functionality into libraries such as JQuery followed. In addition, while at first, Ruby on Rails embraced SOAP, it was later replaced with REST. Ask your mother or grandmother what &lt;a href="http://twitter.com/rickggaribay" target="_blank"&gt;Twitter&lt;/a&gt; or Groupon is and you’ll have the answer as to why REST and JavaScript have persevered. &lt;/p&gt;  &lt;p&gt;In response to all of this, WCF added support for JSON first, followed by REST, and by the release of .NET 4, both were in the box. In addition, WCF RIA Services was introduced, adding an easy button for integrating with Silverlight clients with the stack, and WCF Data Services provided a REST-friendly approach to managing CRUD operations using ATOM as the message contract. The success of the ASP.NET MVC framework, which has all but subsumed its older, less cool ASP.NET Web Forms sibling, is further evidence of the developer and user community embracing the browser as a conduit for interoperability on the client.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Mobility Wars&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Even amidst the mobile revolution, which has been largely built on the ubiquity of broadband connections and increasingly capable handheld devices, proprietary platforms have emerged which in many ways are more restrictive, and costly than any other platform. Want to build apps for iOs? Learn Objective C. Android? Got Java? Windows Phone? .NET. Even though they all sit on similar devices and depend on the same infrastructure for messaging (the internet), apps are hardly interoperable with one another. I am sure you know at least two people that carry multiple headsets with them for this very reason, and tablets, sure to be the next wave of mobile innovation suffer from the same dilemma (if you ask me why HP abandoned WebOS, I think it has more to do with the writing on the wall regarding HTML5 than anything else, but more on that shortly). At first, this dilemma seems somewhat benign, perhaps only affecting developers. The truth is it affects everyone. Talk to any iOS developer (that’s not a complete Apple zealot) and they’ll tell you that Objective C isn’t the most productive language to write apps with. Aside from Java not being too sexy these days, I don’t hear many Android (or WP7) users raving about the selection of apps in Android Market. Same goes for WP7 and Windows Marketplace- I remember how long I had to wait to get Angry Birds on my Windows Phone 7! But the most salient example I can think of is the fact that after a decade of browser wars, tremendous innovation on the client and the server, I still can’t play Flash videos on my iPad or WP7. My iPad refuses to run Silverlight apps, even though its browser on the desktop is fully capable of doing so. This is a situation that is just plain broken, and it isn’t just me that feels this way… &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The World Wants Native Interoperability on the Client, and Today, the Answer is HTML 5.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Like it or not, HTTP has become the ubiquitous interface for both the client and its conduit to the backend. This incredibly simple protocol has had more influence on software over the last decade than any other technology, completely reshaping the strategies of the biggest players. I don’t have to tell you that without HTTP, you don’t have cloud computing. For example, who would have thought that Amazon, after pioneering e-commerce would get into the PaaS business by being the first to truly innovate in commercial cloud computing at scale? Who would think that Microsoft would completely reinvent itself on Windows Azure and invest as deeply in REST as it has, not only with standards and technologies like OData and WCF Data Services, but also in exposing their incredibly rich and powerful Azure APIs as REST heads? Again, the answer is simple. HTTP has become the lingua franca of the interconnected world and the disruption started with the first packet in the early 60s. &lt;/p&gt;  &lt;p&gt;Just as SOAP was developed to aid in interop between vendor platforms, banks and partners, REST has increased the native interoperability of applications on the web. Hold your rotten tomatoes, but I am afraid that so too is the fate of iOS, Android, WP7, WPF, ASP.NET and Silverlight. Are they going away tomorrow, next year or 5 years from now? Nope. SOAP still has a very important place in back-end systems and I don’t mean just for legacy applications. When you you want to work with contracts and interfaces (very important when designing critical message exchanges for business processes), need support for heavy lifting such as distributed transactions, reliable messaging, multiple transports and the like, SOAP is your tool. Case in point as I mentioned briefly above is Windows Azure. While the investment in REST has been significant, these REST endpoints are merely designed for optimizing interop allowing any client or platform to take advantage of the services offered by Microsoft’s cloud. Want to start or stop a compute instance? Need to write a file to blob storage, retrieve an entity from table storage or publish a message for hundreds of subscribers to consume over the AppFabric Service Bus? There’s a REST API for that. While adoption is key to the success of any product or platform, the API, and thus REST is not the end itself but merely a means to the end, and as such is only the tip of the iceberg. Below the water’s surface, there is, and will continue to be a ton of SOAP and .NET.&lt;/p&gt;  &lt;p&gt;The same is happening on the client with HTML5. While Silverlight and ASP.NET MVC were a step in the right direction and aren’t going to just vanish tomorrow, HTML5 offers true interop at the native (browser) level, and since native interop is what the world wants, it will win, at least for now. I say at least for now because as tempting as it is to chock this up to just another trend, unlike the crusty programmer personas I mentioned when I started this stream of consciousness that has become a rather long post (thanks for staying with me this far, btw), I’ve been doing this long enough to have seen software reinvent itself a few times now. I’ve learned that rather than cry over spilled milk, it is important to embrace change and this means you have to expect and be prepared for anything. HTML 5 could fail, and companies that have already invested significantly in ASP.NET, Silverlight, Flash and one (or several) mobile platforms aren’t going to just jump in right away, but they are going to watch very, very carefully. If I am building a web app or a rich client app today from scratch though, I’m going to think very, very hard before I decide to do so in anything but HTML 5.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Who Moved my Cheese?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Who would have thought that Microsoft, with an incredibly lucrative productivity, OS, server and tools business would bet the farm on Windows Azure? As innovative as I think Microsoft’s (PaaS) cloud story is, in many ways, it is the software giant’s response to its cheese being moved by the web. And make no mistake, it is a massive bet. Initial buzz around Windows 8 has so far been met with both positive and quite negative feedback after the revelation that Windows 8 will make HTML 5 a first class citizen on the desktop and the tablet. Viewed simplistically, the seams between client and server/backend are exposed with Windows 8 and Microsoft Azure respectively. At first, this seems quite alarming (&lt;a href="http://www.joelonsoftware.com/articles/APIWar.html" target="_blank"&gt;Joel Spolsky saw this coming&lt;/a&gt; over 8 years ago), but if you think about it, it makes perfect sense. If the client is moving to the browser, the value proposition of a beefy desktop or a rack of servers in an opaque data center is diminished significantly. However, all that data, records, images, videos, files still have to be stored and served up some where, and that somewhere needs to be natively interoperable with the the client at the iceberg and get the heavy lifting done below the water’s surface. The need for middleware- integration between the client, that somewhere and its data, applications and systems has never been greater. &lt;/p&gt;  &lt;p&gt;Even though I’ve joked to friends that stayed on the front end that I didn’t miss anything by skipping WPF and Silverlight because we’re back to where I first began with HTML and JavaScript, the reality is that the last decade has been incredibly important in reinforcing that innovation is bigger than any platform vendor or standards body because unlike them, it is you and me that determine the fate of technology, and for that we should all be proud.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;So, What Now?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I provide no value without designing distributed solutions that can be consumed by the client applications and automate the business processes they serve. So just as before, its time to buckle down once again and learn the client technologies that one of my primary customers- the UI developer- will soon be using. First in line is Mango. Next is HTML 5. And who knows, after specializing in integration for the last 5 years, I just might start generalizing a bit and get back into web development again.&lt;/p&gt;  &lt;p&gt;See you at the other end of the wire.&lt;/p&gt;&lt;img src="http://rickgaribay.net/aggbug/314.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rick G. Garibay</dc:creator>
            <guid>http://rickgaribay.net/archive/2011/08/22/a-middle-tier-guyrsquos-take-on-html-5.aspx</guid>
            <pubDate>Mon, 22 Aug 2011 22:50:58 GMT</pubDate>
            <comments>http://rickgaribay.net/archive/2011/08/22/a-middle-tier-guyrsquos-take-on-html-5.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://rickgaribay.net/comments/commentRss/314.aspx</wfw:commentRss>
            <trackback:ping>http://rickgaribay.net/services/trackbacks/314.aspx</trackback:ping>
        </item>
    </channel>
</rss>
