<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>Clemens Vasters - .NET Services</title>
    <link>http://vasters.com/clemensv/</link>
    <description>Cloud Development and Alien Abductions</description>
    <language>en-us</language>
    <copyright>Clemens Vasters</copyright>
    <lastBuildDate>Tue, 20 Sep 2011 23:54:10 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.7067.0</generator>
    <managingEditor>cvasters@guhhome.com</managingEditor>
    <webMaster>cvasters@guhhome.com</webMaster>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=bb1fc000-b441-445b-8909-104bd754f60d</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,bb1fc000-b441-445b-8909-104bd754f60d.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,bb1fc000-b441-445b-8909-104bd754f60d.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=bb1fc000-b441-445b-8909-104bd754f60d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Load Balancing on the Service Bus Relay is by far our #1 most requested feature now
that we’ve got Queues and Topics finally in production. It’s reasonable expectation
for us deliver that capability in one of the next production updates and the good
news is that we will. I’m not going to promise any concrete ship dates here, but it’d
be sorely disappointing if that wouldn’t happen while the calendar still says 2011. 
</p>
        <p>
I just completed writing the functional spec for the feature and it’s worth communicating
how the feature will show up, since there is a tiny chance that the behavioral change
may affect implementations that rely on a particular exception to drive the strategy
of how to perform failover. 
</p>
        <p>
The gist of the Load Balancing spec is that the required changes in your code and
config to get load balancing are zero. With either the NetTcpRelayBinding or any of
the HTTP bindings (WebHttpRelayBinding, etc) as well as the underlying transport binding
elements, you’ll just open up a second (and third and fourth … up to 25) listener
on the same name and instead of getting an AddressAlreadyInUseException as you get
today, you’ll just get automatic load balancing. When a request for your endpoints
shows up at Service Bus, the system will roll the dice on which of the connected listeners
to route the request or connection/session to and perform the necessary handshake
to make that happen.
</p>
        <p>
The bottom line is that we’re effectively making the AddressAlreadyInUseException
go away for the most part. It’ll still be thrown when the listener’s policy settings
don’t match up, i.e. when one listener wants to have Access Control enabled and the
other one doesn’t, but otherwise you’ll just won’t see it anymore. 
</p>
        <p>
The only way this way of just lighting up the feature may get anyone in trouble is
if your application were to rely on that exception in a situation where you’ve got
an active listener on Service Bus on one node and a ‘standby’ listener on another
node that keeps trying to open up a listener into the same address to create a hot/warm
cluster failover scheme <em>and</em> if the two nodes were tripping over each other
if they were getting traffic concurrently. That doesn’t seem too likely. If you have
questions about this drop me a line here in the comments, by email to clemensv at
microsoft.com or on Twitter @clemensv.  
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=bb1fc000-b441-445b-8909-104bd754f60d" />
      </body>
      <title>Service Bus Relay Load Balancing&amp;ndash;The Missing Feature (But Not For Much Longer!)</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,bb1fc000-b441-445b-8909-104bd754f60d.aspx</guid>
      <link>http://vasters.com/clemensv/2011/09/20/Service+Bus+Relay+Load+BalancingndashThe+Missing+Feature+But+Not+For+Much+Longer.aspx</link>
      <pubDate>Tue, 20 Sep 2011 23:54:10 GMT</pubDate>
      <description>&lt;p&gt;
Load Balancing on the Service Bus Relay is by far our #1 most requested feature now
that we’ve got Queues and Topics finally in production. It’s reasonable expectation
for us deliver that capability in one of the next production updates and the good
news is that we will. I’m not going to promise any concrete ship dates here, but it’d
be sorely disappointing if that wouldn’t happen while the calendar still says 2011. 
&lt;/p&gt;
&lt;p&gt;
I just completed writing the functional spec for the feature and it’s worth communicating
how the feature will show up, since there is a tiny chance that the behavioral change
may affect implementations that rely on a particular exception to drive the strategy
of how to perform failover. 
&lt;/p&gt;
&lt;p&gt;
The gist of the Load Balancing spec is that the required changes in your code and
config to get load balancing are zero. With either the NetTcpRelayBinding or any of
the HTTP bindings (WebHttpRelayBinding, etc) as well as the underlying transport binding
elements, you’ll just open up a second (and third and fourth … up to 25) listener
on the same name and instead of getting an AddressAlreadyInUseException as you get
today, you’ll just get automatic load balancing. When a request for your endpoints
shows up at Service Bus, the system will roll the dice on which of the connected listeners
to route the request or connection/session to and perform the necessary handshake
to make that happen.
&lt;/p&gt;
&lt;p&gt;
The bottom line is that we’re effectively making the AddressAlreadyInUseException
go away for the most part. It’ll still be thrown when the listener’s policy settings
don’t match up, i.e. when one listener wants to have Access Control enabled and the
other one doesn’t, but otherwise you’ll just won’t see it anymore. 
&lt;/p&gt;
&lt;p&gt;
The only way this way of just lighting up the feature may get anyone in trouble is
if your application were to rely on that exception in a situation where you’ve got
an active listener on Service Bus on one node and a ‘standby’ listener on another
node that keeps trying to open up a listener into the same address to create a hot/warm
cluster failover scheme &lt;em&gt;and&lt;/em&gt; if the two nodes were tripping over each other
if they were getting traffic concurrently. That doesn’t seem too likely. If you have
questions about this drop me a line here in the comments, by email to clemensv at
microsoft.com or on Twitter @clemensv.&amp;nbsp; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=bb1fc000-b441-445b-8909-104bd754f60d" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,bb1fc000-b441-445b-8909-104bd754f60d.aspx</comments>
      <category>.NET Services</category>
      <category>AppFabric</category>
      <category>Architecture</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=13a56656-e8f4-4154-8cf9-cf2480536389</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,13a56656-e8f4-4154-8cf9-cf2480536389.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,13a56656-e8f4-4154-8cf9-cf2480536389.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=13a56656-e8f4-4154-8cf9-cf2480536389</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This session explains how to secure Service Bus using the Access Control Service.
This is also an extension session for <a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-862T">my
session at BUILD</a>, but watching the BUILD session is not a strict prerequisite.
</p>
        <iframe style="WIDTH: 512px; HEIGHT: 288px" src="http://channel9.msdn.com/posts/Securing-Service-Bus-with-ACS/player?w=512&amp;h=288" frameborder="0" scrolling="no">
        </iframe>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=13a56656-e8f4-4154-8cf9-cf2480536389" />
      </body>
      <title>Securing Service Bus with the Access Control Service</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,13a56656-e8f4-4154-8cf9-cf2480536389.aspx</guid>
      <link>http://vasters.com/clemensv/2011/09/19/Securing+Service+Bus+With+The+Access+Control+Service.aspx</link>
      <pubDate>Mon, 19 Sep 2011 19:00:29 GMT</pubDate>
      <description>&lt;p&gt;
This session explains how to secure Service Bus using the Access Control Service.
This is also an extension session for &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-862T"&gt;my
session at BUILD&lt;/a&gt;, but watching the BUILD session is not a strict prerequisite.
&lt;/p&gt;
&lt;iframe style="WIDTH: 512px; HEIGHT: 288px" src="http://channel9.msdn.com/posts/Securing-Service-Bus-with-ACS/player?w=512&amp;amp;h=288" frameborder=0 scrolling=no&gt;
&lt;/iframe&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=13a56656-e8f4-4154-8cf9-cf2480536389" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,13a56656-e8f4-4154-8cf9-cf2480536389.aspx</comments>
      <category>.NET Services</category>
      <category>AppFabric</category>
      <category>Azure</category>
      <category>Talks</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=44c95cba-0951-4f92-96e2-1366b516f72c</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,44c95cba-0951-4f92-96e2-1366b516f72c.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,44c95cba-0951-4f92-96e2-1366b516f72c.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=44c95cba-0951-4f92-96e2-1366b516f72c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This session is a followup to the Service Bus session <a href="http://vasters.com/clemensv/2011/09/16/Building+Looselycoupled+Apps+With+Windows+Azure+Service+Bus+Topics+And+Queues.aspx">that
I did at the build conference</a> and explains advanced usage patterns:
</p>
        <p>
          <iframe style="WIDTH: 512px; HEIGHT: 288px" src="http://channel9.msdn.com/posts/ServiceBusTopicsAndQueues/player?w=512&amp;h=288" frameborder="0" scrolling="no">
          </iframe>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=44c95cba-0951-4f92-96e2-1366b516f72c" />
      </body>
      <title>Service Bus Topics and Queues &amp;ndash; Advanced</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,44c95cba-0951-4f92-96e2-1366b516f72c.aspx</guid>
      <link>http://vasters.com/clemensv/2011/09/19/Service+Bus+Topics+And+Queues+Ndash+Advanced.aspx</link>
      <pubDate>Mon, 19 Sep 2011 02:15:26 GMT</pubDate>
      <description>&lt;p&gt;
This session is a followup to the Service Bus session &lt;a href="http://vasters.com/clemensv/2011/09/16/Building+Looselycoupled+Apps+With+Windows+Azure+Service+Bus+Topics+And+Queues.aspx"&gt;that
I did at the build conference&lt;/a&gt; and explains advanced usage patterns:
&lt;/p&gt;
&lt;p&gt;
&lt;iframe style="WIDTH: 512px; HEIGHT: 288px" src="http://channel9.msdn.com/posts/ServiceBusTopicsAndQueues/player?w=512&amp;amp;h=288" frameborder=0 scrolling=no&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=44c95cba-0951-4f92-96e2-1366b516f72c" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,44c95cba-0951-4f92-96e2-1366b516f72c.aspx</comments>
      <category>.NET Services</category>
      <category>AppFabric</category>
      <category>Azure</category>
      <category>Talks</category>
      <category>Technology/MSMQ</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=bf4c0637-7829-44e3-a2c4-0f2f135fb686</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,bf4c0637-7829-44e3-a2c4-0f2f135fb686.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,bf4c0637-7829-44e3-a2c4-0f2f135fb686.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=bf4c0637-7829-44e3-a2c4-0f2f135fb686</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At the bottom of this post you’ll find the DinnerNow version that I’ve been using
for my PDC09 talk. The video of that talk is now available at <a title="http://microsoftpdc.com/Sessions/SVC18" href="http://microsoftpdc.com/Sessions/SVC18">http://microsoftpdc.com/Sessions/SVC18</a> and
I recommend that you listen to the talk for context. 
</p>
        <p>
The DinnerNow drop I’m sharing here is a customized version of the <a href="http://dinnernow.net/">DinnerNow
3.1 version that’s up on CodePlex</a>. If I were you, I’d install the original version
and then unpack my zip file alongside of it and then use some kind of diff tool (the
Windows SDK’s WinDiff tool is a start) to look at the differences between the versions.
That will give you a raw overview of what I had to do. You’ll find that I had to add
and move a few things, but that the app didn’t change in any radical way.
</p>
        <p>
Remember that looking at the code is more important that making it run. There’s one
particular challenge you’d have right now with the Windows Azure CTP and that’s getting
the two (!) Windows Azure compute tokens needed for separating out the web and the
service tier as I’ve done here. It’s not difficult to consolidate the Web and the
Web Service tier into a single role, but since I had to do the migration within a
short period of time, I chose to split them up. 
</p>
        <p>
FWIW, I time-boxed the migration to 3 work days – which included learning about what
our buddies over in SQL Azure had done in the past months — and that turned out to
be a comfortable fit in terms of time.
</p>
        <p>
Another function of time-boxing is that you’re finding me disabling security on most
endpoints, including disabling the Access Control integration with Service Bus for
most endpoints by setting the <em>relayClientAuthenticationType</em> attribute on
the respective binding elements to <em>None</em>. 
</p>
        <p>
I know that’s a sin, but I didn’t want to cause too much churn in the first iteration.
The original version of DinnerNow is conveniently using Windows authentication/authorization
for its communication paths. While that’s ok for a LAN setup, things get more complicated
for an actual WAN setup that the DinnerNow scenario calls for. That would spawn a
wholly different discussion that shines the spotlight on our Access Control service
and why it’s useful – even required – for that scenario. In order not to overwhelm
everyone, I left that out for this round and will revisit that aspect in the next
weeks – or maybe one of our (aspiring?) MVPs or RDs will beat me to it.
</p>
        <p>
I’m also going to work with the guys who wrote DinnerNow to find a way to host this
modified version of Dinner Now with the on-premise runtime bits expressly not on my
primary dev machine, where they’d live now. 
</p>
        <p>
 
</p>
        <p>
          <strong>Here what you need to do to get it to run</strong>
        </p>
        <p>
I know this is rough. Writing up the long version of this is going to take some time
and I prefer getting the bits to you early over me sitting here writing pages of docs.
Maybe you can even help ;-) 
</p>
        <ol>
          <li>
First, you’ll need to go to the Windows Azure portal and get the SDKs and tokens/accounts.
The <a href="http://www.microsoft.com/windowsazure/getstarted/">Getting Started</a> page
has all the data and links you need so I’m not going to repeat them here in much detail.
You will need at least one Windows Azure compute account (<a href="https://connect.microsoft.com/Survey/NominationSurvey.aspx?SurveyID=7044&amp;ProgramID=2500&amp;SiteID=681">apply
here</a>), one SQL Azure account (<a href="https://connect.microsoft.com/SQLAzure/Survey/NominationSurvey.aspx?SurveyID=5719&amp;ProgramID=2089">apply
here</a>), and an AppFabric account (no application needed, <a href="https://netservices.azure.com/">just
log in w/ LiveID</a>).  
</li>
          <li>
Download and install the regular version <a href="http://dinnernow.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=31480">DinnerNow
3.1 from Codeplex</a>. This will drop a “Configure DinnerNow 3.1” shortcut on your
desktop. Run that, install all prerequisites and make sure DinnerNow runs locally
before you proceed. 
</li>
          <li>
You will later need the databases that the setup created in your local SQLEXPRESS
instance by setup. You’ll have to make a few changes, though. 
<ol><li>
First, (<a href="http://www.microsoft.com/downloads/details.aspx?familyid=08E52AC2-1D62-45F6-9A4A-4B76A8564A2B&amp;displaylang=en">download,
install</a>, and) open SQL Server Management Studio, connect to your SQL Server Express
instance and switch to “SQL Server and Windows Authentication mode” on the <em>Server
Properties</em> under <em>Security</em>. Then you’ll need to go to to the Security
settings and either create a new account and grant it all rights on the <strong>aspnetdb</strong> database
or just enable the ‘sa’ account and set its password.  
</li><li>
Then you need to find the “SQL Server Configuration Manager” and enable TCP for your
SQLEXPRESS instance <a href="http://msdn.microsoft.com/en-us/library/ms165718.aspx">like
this</a>. The default port will be 1433. If you have a full SQL Server instance on
your dev machine and it’s configured for TCP the easiest is to suspend that for the
moment and allow the SQLEXPRESS instance to squat the port.</li></ol></li>
          <li>
Unpack the ZIP file appended below into a directory on your machine. At this point
it should be ok to override the existing DinnerNow directory, but I’d keep things
side-by-side for reference. If you copy side-by-side, grab the ./solution/DinnerNow
– Web/DinnerNow.WebUX/images/’ directory from your local installation and copy it
into the location where you unzipped the file here. I left out the images due to their
size. And just as with the normal DinnerNow installation you’ll find a solution file
named “<strong>DinnerNow  - Main.sln</strong>” in the unpacked directory – open
that in Visual Studio 2008 (not 2010!) because you’ll have to make some changes and
edits. 
</li>
          <li>
If you are lucky enough to have two Windows Azure compute accounts, you can skip this
step. Otherwise, you will have to restructure the application a bit:  
<ol><li>
In the <em>“DinnerNow – WA” </em>solution branch where the Windows Azure deployment
project reside you’ll have to consolidate the <em>DinnerNow.WindowsAzure</em> project
and the <em>DinnerNow.WindowsAzureAppSrv </em>projects into one by replicating the <em>DinnerNow.DBBridge</em> reference
into the <em>DinnerNow.WindowsAzure</em> project and abandoning/deleting the rest. 
</li><li>
In the “<em>DinnerNow – Web”</em> solution branch you will have to modify the <em>DinnerNow.WebUX</em> project
by merging the DinnerNow.ServiceHost project from the “<em>DinnerNow -ServicePortfolio2” </em>branch
into it, including merging the config files. In the original DinnerNow the hosting
default is that the ServiceHost  project lives in the ./services subdirectory
of the WebUX app. You can also do it that way, but you’ll have to change the respective
client URIs to point to the right path.</li></ol></li>
          <li>
In the ./database directory is a file called <em>SQLAzureImport.sql. </em>That’s the
exported and customized script for the DinnerNow restaurants and menus database. Create
a new database (1GB is enough) and load the DB with this script. You can do this with
the command line or with SQL Management Studio. <a href="http://msdn.microsoft.com/en-us/library/ee621784.aspx">The
SQL Azure docs will tell you how</a>. 
</li>
          <li>
Now you’ll need to do a range of search/replace steps across the whole project. These
are mostly in *.config files - a few places are in the code, which I count as bugs,
but those are faithfully carried over from the original: 
<ol><li>
Find all occurrences of <strong>sqlazure-instance</strong> and replace them with your
unqualified SQL Azure <em>server name</em> (might look like this: tn0a1b2c3d) 
</li><li>
Find all occurrences of <strong>sqlazure-dbname</strong> and replace them with your
SQL Azure <em>database name</em></li><li>
Find all occurrences of <strong>sqlazure-acct</strong> and replace them with your
SQL Azure <em>administrator username</em></li><li>
Find all occurrences of <strong>sqlazure-password</strong> and replace them with your
SQL Azure <em>administrator password</em></li><li>
Find all occurrences of <strong>appfabricservicebus-ns</strong> and replace them with
your unqualified AppFabric <em>namespace name</em></li><li>
Find all occurrences of <strong>appfabricservicebus-key</strong> and replace them
with your AppFabric <em>Service Bus</em><em>issuer key</em></li><li>
Find all occurrences of <strong>windowsazuresvcrole-acct</strong> and replace them
with the name of your Windows Azure compute account. If you have just one, use that
(given you’ve done the rework in step 4), if you have two use the account-name where
you will host the service tier. 
</li><li>
Find all occurrences of <strong>sqlserver-password</strong> and replace them with
your <em>local<strong></strong></em>SQL Server Express instance’s ‘sa’ account password. 
</li></ol></li>
          <li>
Do a full batch Rebuild of the whole project 
</li>
          <li>
Go to the “DinnerNow –WA” solution and publish the project(s) to your Windows Azure
compute account(s). If you had to consolidate them you’ll have one package to deploy,
if you left things as they are you’ll have two packages to deploy. You can also run
these packages in the local DevFabric to test things out. 
</li>
          <li>
The executables you need to run are going to be dropped into the .\bin directory by
the build. You need to run all 6 apps – but you could run them on 6 different machines
– the two workflow hosts each assume the local presence of the DinnerNowWF database: 
<ol><li><strong>CloudTraceRecorder.exe</strong> – this is the simple event listener app. You
can run this right away to observe the apps starting up inside of Azure as they write
events to the event listener. You can and should run this as you deploy. You can run
any number of instances of CloudTraceRecorder anywhere. 
</li><li><strong>PortBridge.exe</strong> – this is the on-premise bridge-head for bridging
to your local SQL Server Express instance so that the cloud application can get at
its membership database that you host for it on your machine. After the search/replace
steps you will notice that you have modified connection strings that point to a SQL
Server role peeking out of your *AppSrv role. The secret ingredient is in the DinnerNow.DBBridge
role that’s listening for TCP connections on behalf of your on-premise SQL Server
and that connects them down to your local server with the logic in <em>Microsoft.Samples.ServiceBus.Connections</em>.
This is the same code that’s in <a href="http://vasters.com/clemensv/PermaLink,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx">PortBridge</a>. 
</li><li><strong>DinnerNow.OrderProcessingHost.exe</strong> is the (new) host application for
the workflow that handles the order process. 
</li><li><strong>DinnerNow.RestaurantProcessingHost.exe</strong> is the (new) host application
for the workflow that handles the restaurant process. 
</li><li><strong>DinnerNowKiosk.exe</strong> is the only slightly modified version of the DinnerNow
in-restaurant kiosk 
</li><li>
Not in .\bin but rather to be started/deployed from VS is the also just slightly modified
Windows Mobile app for the delivery app</li></ol></li>
        </ol>
        <p>
 
</p>
        <p>
Please also mind that the DinnerNow Powershell support and the other test and diagnostics
capabilities haven’t been touched here, yet. 
</p>
        <p>
Oh, and … this is provided as-is … I’ll do my best to discuss some of the patterns
over the next several weeks, but I don’t have time to provide 1:1 support.
</p>
        <p>
Here’s the code:
</p>
        <a href="http://vasters.com/clemensv/content/binary/DinnerNow-SVC18-PDC09.zip">DinnerNow-SVC18-PDC09.zip
(2.35 MB)</a>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=bf4c0637-7829-44e3-a2c4-0f2f135fb686" />
      </body>
      <title>The Rough Setup Script for PDC09 SVC18 - Getting DinnerNow! to run on Windows Azure</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,bf4c0637-7829-44e3-a2c4-0f2f135fb686.aspx</guid>
      <link>http://vasters.com/clemensv/2009/11/23/The+Rough+Setup+Script+For+PDC09+SVC18+Getting+DinnerNow+To+Run+On+Windows+Azure.aspx</link>
      <pubDate>Mon, 23 Nov 2009 23:42:16 GMT</pubDate>
      <description>&lt;p&gt;
At the bottom of this post you’ll find the DinnerNow version that I’ve been using
for my PDC09 talk. The video of that talk is now available at &lt;a title=http://microsoftpdc.com/Sessions/SVC18 href="http://microsoftpdc.com/Sessions/SVC18"&gt;http://microsoftpdc.com/Sessions/SVC18&lt;/a&gt; and
I recommend that you listen to the talk for context. 
&lt;/p&gt;
&lt;p&gt;
The DinnerNow drop I’m sharing here is a customized version of the &lt;a href="http://dinnernow.net/"&gt;DinnerNow
3.1 version that’s up on CodePlex&lt;/a&gt;. If I were you, I’d install the original version
and then unpack my zip file alongside of it and then use some kind of diff tool (the
Windows SDK’s WinDiff tool is a start) to look at the differences between the versions.
That will give you a raw overview of what I had to do. You’ll find that I had to add
and move a few things, but that the app didn’t change in any radical way.
&lt;/p&gt;
&lt;p&gt;
Remember that looking at the code is more important that making it run. There’s one
particular challenge you’d have right now with the Windows Azure CTP and that’s getting
the two (!) Windows Azure compute tokens needed for separating out the web and the
service tier as I’ve done here. It’s not difficult to consolidate the Web and the
Web Service tier into a single role, but since I had to do the migration within a
short period of time, I chose to split them up. 
&lt;/p&gt;
&lt;p&gt;
FWIW, I time-boxed the migration to 3 work days – which included learning about what
our buddies over in SQL Azure had done in the past months — and that turned out to
be a comfortable fit in terms of time.
&lt;/p&gt;
&lt;p&gt;
Another function of time-boxing is that you’re finding me disabling security on most
endpoints, including disabling the Access Control integration with Service Bus for
most endpoints by setting the &lt;em&gt;relayClientAuthenticationType&lt;/em&gt; attribute on
the respective binding elements to &lt;em&gt;None&lt;/em&gt;. 
&lt;/p&gt;
&lt;p&gt;
I know that’s a sin, but I didn’t want to cause too much churn in the first iteration.
The original version of DinnerNow is conveniently using Windows authentication/authorization
for its communication paths. While that’s ok for a LAN setup, things get more complicated
for an actual WAN setup that the DinnerNow scenario calls for. That would spawn a
wholly different discussion that shines the spotlight on our Access Control service
and why it’s useful – even required – for that scenario. In order not to overwhelm
everyone, I left that out for this round and will revisit that aspect in the next
weeks – or maybe one of our (aspiring?) MVPs or RDs will beat me to it.
&lt;/p&gt;
&lt;p&gt;
I’m also going to work with the guys who wrote DinnerNow to find a way to host this
modified version of Dinner Now with the on-premise runtime bits expressly not on my
primary dev machine, where they’d live now. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Here what you need to do to get it to run&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I know this is rough. Writing up the long version of this is going to take some time
and I prefer getting the bits to you early over me sitting here writing pages of docs.
Maybe you can even help ;-) 
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
First, you’ll need to go to the Windows Azure portal and get the SDKs and tokens/accounts.
The &lt;a href="http://www.microsoft.com/windowsazure/getstarted/"&gt;Getting Started&lt;/a&gt; page
has all the data and links you need so I’m not going to repeat them here in much detail.
You will need at least one Windows Azure compute account (&lt;a href="https://connect.microsoft.com/Survey/NominationSurvey.aspx?SurveyID=7044&amp;amp;ProgramID=2500&amp;amp;SiteID=681"&gt;apply
here&lt;/a&gt;), one SQL Azure account (&lt;a href="https://connect.microsoft.com/SQLAzure/Survey/NominationSurvey.aspx?SurveyID=5719&amp;amp;ProgramID=2089"&gt;apply
here&lt;/a&gt;), and an AppFabric account (no application needed, &lt;a href="https://netservices.azure.com/"&gt;just
log in w/ LiveID&lt;/a&gt;).&amp;nbsp; 
&lt;li&gt;
Download and install the regular version &lt;a href="http://dinnernow.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=31480"&gt;DinnerNow
3.1 from Codeplex&lt;/a&gt;. This will drop a “Configure DinnerNow 3.1” shortcut on your
desktop. Run that, install all prerequisites and make sure DinnerNow runs locally
before you proceed. 
&lt;li&gt;
You will later need the databases that the setup created in your local SQLEXPRESS
instance by setup. You’ll have to make a few changes, though. 
&lt;ol&gt;
&lt;li&gt;
First, (&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=08E52AC2-1D62-45F6-9A4A-4B76A8564A2B&amp;amp;displaylang=en"&gt;download,
install&lt;/a&gt;, and) open SQL Server Management Studio, connect to your SQL Server Express
instance and switch to “SQL Server and Windows Authentication mode” on the &lt;em&gt;Server
Properties&lt;/em&gt; under &lt;em&gt;Security&lt;/em&gt;. Then you’ll need to go to to the Security
settings and either create a new account and grant it all rights on the &lt;strong&gt;aspnetdb&lt;/strong&gt; database
or just enable the ‘sa’ account and set its password.&amp;nbsp; 
&lt;li&gt;
Then you need to find the “SQL Server Configuration Manager” and enable TCP for your
SQLEXPRESS instance &lt;a href="http://msdn.microsoft.com/en-us/library/ms165718.aspx"&gt;like
this&lt;/a&gt;. The default port will be 1433. If you have a full SQL Server instance on
your dev machine and it’s configured for TCP the easiest is to suspend that for the
moment and allow the SQLEXPRESS instance to squat the port.&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;
Unpack the ZIP file appended below into a directory on your machine. At this point
it should be ok to override the existing DinnerNow directory, but I’d keep things
side-by-side for reference. If you copy side-by-side, grab the ./solution/DinnerNow
– Web/DinnerNow.WebUX/images/’ directory from your local installation and copy it
into the location where you unzipped the file here. I left out the images due to their
size. And just as with the normal DinnerNow installation you’ll find a solution file
named “&lt;strong&gt;DinnerNow&amp;nbsp; - Main.sln&lt;/strong&gt;” in the unpacked directory – open
that in Visual Studio 2008 (not 2010!) because you’ll have to make some changes and
edits. 
&lt;li&gt;
If you are lucky enough to have two Windows Azure compute accounts, you can skip this
step. Otherwise, you will have to restructure the application a bit:&amp;nbsp; 
&lt;ol&gt;
&lt;li&gt;
In the &lt;em&gt;“DinnerNow – WA” &lt;/em&gt;solution branch where the Windows Azure deployment
project reside you’ll have to consolidate the &lt;em&gt;DinnerNow.WindowsAzure&lt;/em&gt; project
and the &lt;em&gt;DinnerNow.WindowsAzureAppSrv &lt;/em&gt;projects into one by replicating the &lt;em&gt;DinnerNow.DBBridge&lt;/em&gt; reference
into the &lt;em&gt;DinnerNow.WindowsAzure&lt;/em&gt; project and abandoning/deleting the rest. 
&lt;li&gt;
In the “&lt;em&gt;DinnerNow – Web”&lt;/em&gt; solution branch you will have to modify the &lt;em&gt;DinnerNow.WebUX&lt;/em&gt; project
by merging the DinnerNow.ServiceHost project from the “&lt;em&gt;DinnerNow -ServicePortfolio2” &lt;/em&gt;branch
into it, including merging the config files. In the original DinnerNow the hosting
default is that the ServiceHost&amp;nbsp; project lives in the ./services subdirectory
of the WebUX app. You can also do it that way, but you’ll have to change the respective
client URIs to point to the right path.&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;
In the ./database directory is a file called &lt;em&gt;SQLAzureImport.sql. &lt;/em&gt;That’s the
exported and customized script for the DinnerNow restaurants and menus database. Create
a new database (1GB is enough) and load the DB with this script. You can do this with
the command line or with SQL Management Studio. &lt;a href="http://msdn.microsoft.com/en-us/library/ee621784.aspx"&gt;The
SQL Azure docs will tell you how&lt;/a&gt;. 
&lt;li&gt;
Now you’ll need to do a range of search/replace steps across the whole project. These
are mostly in *.config files - a few places are in the code, which I count as bugs,
but those are faithfully carried over from the original: 
&lt;ol&gt;
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlazure-instance&lt;/strong&gt; and replace them with your
unqualified SQL Azure &lt;em&gt;server name&lt;/em&gt; (might look like this: tn0a1b2c3d) 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlazure-dbname&lt;/strong&gt; and replace them with your
SQL Azure &lt;em&gt;database name&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlazure-acct&lt;/strong&gt; and replace them with your
SQL Azure &lt;em&gt;administrator username&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlazure-password&lt;/strong&gt; and replace them with your
SQL Azure &lt;em&gt;administrator password&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;appfabricservicebus-ns&lt;/strong&gt; and replace them with
your unqualified AppFabric &lt;em&gt;namespace name&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;appfabricservicebus-key&lt;/strong&gt; and replace them
with your AppFabric &lt;em&gt;Service Bus&lt;/em&gt; &lt;em&gt;issuer key&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;windowsazuresvcrole-acct&lt;/strong&gt; and replace them
with the name of your Windows Azure compute account. If you have just one, use that
(given you’ve done the rework in step 4), if you have two use the account-name where
you will host the service tier. 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlserver-password&lt;/strong&gt; and replace them with
your &lt;em&gt;local&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;SQL Server Express instance’s ‘sa’ account password. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;
Do a full batch Rebuild of the whole project 
&lt;li&gt;
Go to the “DinnerNow –WA” solution and publish the project(s) to your Windows Azure
compute account(s). If you had to consolidate them you’ll have one package to deploy,
if you left things as they are you’ll have two packages to deploy. You can also run
these packages in the local DevFabric to test things out. 
&lt;li&gt;
The executables you need to run are going to be dropped into the .\bin directory by
the build. You need to run all 6 apps – but you could run them on 6 different machines
– the two workflow hosts each assume the local presence of the DinnerNowWF database: 
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;CloudTraceRecorder.exe&lt;/strong&gt; – this is the simple event listener app. You
can run this right away to observe the apps starting up inside of Azure as they write
events to the event listener. You can and should run this as you deploy. You can run
any number of instances of CloudTraceRecorder anywhere. 
&lt;li&gt;
&lt;strong&gt;PortBridge.exe&lt;/strong&gt; – this is the on-premise bridge-head for bridging
to your local SQL Server Express instance so that the cloud application can get at
its membership database that you host for it on your machine. After the search/replace
steps you will notice that you have modified connection strings that point to a SQL
Server role peeking out of your *AppSrv role. The secret ingredient is in the DinnerNow.DBBridge
role that’s listening for TCP connections on behalf of your on-premise SQL Server
and that connects them down to your local server with the logic in &lt;em&gt;Microsoft.Samples.ServiceBus.Connections&lt;/em&gt;.
This is the same code that’s in &lt;a href="http://vasters.com/clemensv/PermaLink,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx"&gt;PortBridge&lt;/a&gt;. 
&lt;li&gt;
&lt;strong&gt;DinnerNow.OrderProcessingHost.exe&lt;/strong&gt; is the (new) host application for
the workflow that handles the order process. 
&lt;li&gt;
&lt;strong&gt;DinnerNow.RestaurantProcessingHost.exe&lt;/strong&gt; is the (new) host application
for the workflow that handles the restaurant process. 
&lt;li&gt;
&lt;strong&gt;DinnerNowKiosk.exe&lt;/strong&gt; is the only slightly modified version of the DinnerNow
in-restaurant kiosk 
&lt;li&gt;
Not in .\bin but rather to be started/deployed from VS is the also just slightly modified
Windows Mobile app for the delivery app&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Please also mind that the DinnerNow Powershell support and the other test and diagnostics
capabilities haven’t been touched here, yet. 
&lt;/p&gt;
&lt;p&gt;
Oh, and … this is provided as-is … I’ll do my best to discuss some of the patterns
over the next several weeks, but I don’t have time to provide 1:1 support.
&lt;/p&gt;
&lt;p&gt;
Here’s the code:
&lt;/p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/DinnerNow-SVC18-PDC09.zip"&gt;DinnerNow-SVC18-PDC09.zip
(2.35 MB)&lt;/a&gt;&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=bf4c0637-7829-44e3-a2c4-0f2f135fb686" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,bf4c0637-7829-44e3-a2c4-0f2f135fb686.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
      <category>Talks</category>
      <category>AppFabric</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3e35d8bd-b755-453f-8c63-1a57c570eb4c</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3e35d8bd-b755-453f-8c63-1a57c570eb4c</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Building “hybrid” cloud applications where parts of an an app lives up in a cloud
infrastructure and other parts of the infrastructure live at a hosting site, or a
data center, or even in your house ought to be simple – especially in this day and
age of Web services. You create a Web service, make it accessible through your firewall
and NAT, and the the cloud-hosted app calls it. That’s as easy as it ought to be.
</p>
        <p>
Unfortunately it’s not always that easy. If the server sits behind an Internet connection
with dynamically assigned IP addresses, if the upstream ISP is blocking select ports,
if it’s not feasible to open up inbound firewall ports, or if you have no influence
over the infrastructure whatsoever, reaching an on-premise service from the cloud
(or anywhere else) is a difficult thing to do. For these scenarios (and others) our
team is building the <em><a href="http://msdn.microsoft.com/en-us/azure/netservices.aspx">Windows
Azure platform AppFabric</a> Service Bus</em> (friends call us just <em>Service Bus</em>). 
</p>
        <p>
Now – the Service Bus and the client bits in the <em>Microsoft.ServiceBus.dll </em>assembly
are great if you have services can can be readily hooked up into the Service Bus because
they’re built with WCF. For services that aren’t built with WCF, but are at least
using HTTP, I’ve <a href="http://vasters.com/clemensv/PermaLink,guid,83edb04a-5696-401c-a919-8c1f379d130c.aspx">previously
shown a way</a> to hook them into Service Bus and have also demoed an updated version
of that capability at Sun’s Java One. I’ll release an update for those bits tomorrow
after my talk at PDC09 – the version currently here on my blog (ironically) doesn’t
play well with SOAP and also doesn’t have rewrite capabilities for WSDL. The new version
does. 
</p>
        <p>
But what if your service isn’t a WCF service or doesn’t speak HTTP? What if it speaks
SMTP, SNMP, POP, IMAP, RDP, TDS, SSH, ETC? 
</p>
        <p>
          <strong>Introducing Port Bridge</strong>
        </p>
        <p>
“Port Bridge” – which is just a descriptive name for this code sample, not an attempt
at branding – is a point-to-point tunneling utility to help with these scenarios.
Port Bridge consists of two components, the “Port Bridge Service” and the “Port Bridge
Agent”. Here’s a picture:
</p>
        <p>
          <a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/865a80e15ca0_D9A4/image_2.png">
            <img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title="image" border="0" alt="image" src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/865a80e15ca0_D9A4/image_thumb.png" width="611" height="220" />
          </a>
        </p>
        <p>
The Agent’s job is to listen for and accept TCP or Named Pipe connections on a configurable
port or local pipe name. The Service’s job is to accept for incoming connections from
the Agent, establish a duplex channel with the Agent, and pump the data from the Agent
to the actual listening service – and vice versa. It’s actually quite simple. In the
picture above you see that the Service is configured to connect to a SQL Server listening
at the SQL Server default port 1433 and that the Agent – running on a different machine,
is listening on port 1433 as well, thus mapping the remote SQL Server onto the Agent
machine as if it ran there. You can (and I think of that as to be more common) map
the service on the Agent to any port you like – say higher up at 41433.
</p>
        <p>
In order to increase the responsiveness and throughput for protocols that are happy
to kill and reestablish connections such as HTTP does, “Port Bridge” is always multiplexing
concurrent traffic that’s flowing between two parties on the same logical socket.
When using Port Bridge to bridge to a remote HTTP proxy that the Service machine can
see, but the Agent machine can’t see (which turns out to be the at-home scenario that
this capability emerged from) there are very many and very short-lived connections
being tunneled through the channel. Creating a new Service Bus channel for each of
these connections is feasible – but not very efficient. Holding on to a connection
for an extended period of time and multiplexing traffic over it is also beneficial
in the Port Bridge case because it is using the Service Bus <em>Hybrid</em> connection
mode by default. With <em>Hybrid</em>, all connections are first established through
the Service Bus Relay and then our bits do a little “NAT dance” trying to figure out
whether there’s a way to connect both parties with a direct socket – if that works
the connection gets upgraded to the most direct connections in-flight. The probing,
handshake, and upgrade of the socket may take 2-20 seconds and there’s some degree
of luck involved to get that direct socket established on a very busy NAT – and thus
we want to maximize the use of that precious socket instead of throwing it away all
the time.
</p>
        <p>
          <strong>That seems familiar?!</strong>
        </p>
        <p>
You may notice that <a href="http://vasters.com/clemensv/PermaLink,guid,26dc5df1-8b8c-4f71-8765-8904e584505b.aspx">SocketShifter</a> (built
by our friends at <a href="http://www.aws.net/">AWS in the UK</a>) is quite similar
to Port Bridge. Even though the timing of the respective releases may not suggest
it, Port Bridge is indeed Socketshifter’s older brother. Because we couldn’t make
up our mind on whether to release Port Bridge for a while, I had AWS take a look at
the service contract shown below and explained a few principles that I’m also explaining
here and they had a first version of Socketshifter running within a few hours. There’s
nothing wrong with having two variants of the same thing. 
</p>
        <p>
          <strong>How does it work?</strong>
        </p>
        <p>
Since I’m publishing this as a sample, I obviously need to spend a little time on
the “how”, even I’ll limit that here and will explain that in more detail in a future
post. At the heart of the app, the contract that’s used between the Agent and the
Service is a simple duplex WCF contract:
</p>
        <pre class="code">    [<span style="COLOR: #2b91af">ServiceContract</span>(Namespace=<span style="COLOR: #a31515">"n:"</span>,
Name=<span style="COLOR: #a31515">"idx"</span>, CallbackContract=<span style="COLOR: blue">typeof</span>(<span style="COLOR: #2b91af">IDataExchange</span>),
SessionMode=<span style="COLOR: #2b91af">SessionMode</span>.Required)] <span style="COLOR: blue">public
interface </span><span style="COLOR: #2b91af">IDataExchange </span>{ [<span style="COLOR: #2b91af">OperationContract</span>(Action=<span style="COLOR: #a31515">"c"</span>,
IsOneWay = <span style="COLOR: blue">true</span>, IsInitiating=<span style="COLOR: blue">true</span>)] <span style="COLOR: blue">void </span>Connect(<span style="COLOR: blue">string </span>i);
[<span style="COLOR: #2b91af">OperationContract</span>(Action = <span style="COLOR: #a31515">"w"</span>,
IsOneWay = <span style="COLOR: blue">true</span>)] <span style="COLOR: blue">void </span>Write(<span style="COLOR: #2b91af">TransferBuffer </span>d);
[<span style="COLOR: #2b91af">OperationContract</span>(Action = <span style="COLOR: #a31515">"d"</span>,
IsOneWay = <span style="COLOR: blue">true</span>, IsTerminating = <span style="COLOR: blue">true</span>)] <span style="COLOR: blue">void </span>Disconnect();
}</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
There’s a way to establish a session, send data either way, and close the session.
The <em>TransferBuffer</em> type is really just a trick to avoid extra buffer copies
during serialization for efficiency reasons. But that’s it. The rest of Port Bridge
is a set of queue-buffered streams and pumps to make the data packets flow smoothly
and to accept inbound sockets/pipes and dispatch them out to the proxied services.
What’s noteworthy is that Port Bridge doesn’t use WCF streaming, but sends data in
chunks – which allows for much better flow control and enables multiplexing.
</p>
        <p>
Now you might say <em>You are using a WCF ServiceContract?</em> <em>Isn’t that
using SOAP and doesn’t that cause ginormous overhead?</em> No, it doesn’t. We’re using
the WCF binary encoder in session mode here. That’s about as efficient as you can
get it on the wire with serialized data. The per-frame SOAP overhead for net.tcp with
the binary encoder in session mode is in the order of 40-50 bytes per message because
of dictionary-based metadata compression. The binary encoder also isn’t doing any
base64 trickery but treats binary as binary – one byte is one byte. Port Bridge is
using a default frame size of 64K (which gets filled up in high-volume streaming cases
due to the built-in Nagling support) and so we’re looking at an overhead of far less
than 0.1%. That’s not shabby. 
</p>
        <p>
          <strong>How do I use it?</strong>
        </p>
        <p>
This is a code sample and thus you’ll have to build it using Visual Studio 2008. You’ll
find three code projects: <em>PortBridge</em> (the Service), <em>PortBridgeAgent</em> (the
Agent), and the <em>Microsoft.Samples.ServiceBus.Connections</em> assembly that contains
the bulk of the logic for Port Bridge. It’s mostly straightforward to embed the agent
side or the service side into other hosts and I’ll show that in a separate post. 
</p>
        <p>
          <strong>Service</strong>
        </p>
        <p>
The service’s exe file is “PortBridge.exe” and is both a console app and a Windows
Service. If the Windows Service isn’t registered, the app will always start as a console
app. If the Windows Service is registered (with the installer or with installutil.exe)
you can force console-mode with the –c command line option.
</p>
        <p>
The app.config file on the Service Side (PortBridge/app.config, PortBridge.exe.config
in the binaries folder) specifies what ports or named pipes you want to project into
Service Bus:
</p>
        <pre class="code">
          <span style="COLOR: blue"> &lt;</span>
          <span style="COLOR: #a31515">portBridge </span>
          <span style="COLOR: red">serviceBusNamespace</span>
          <span style="COLOR: blue">=</span>"<span style="COLOR: blue">mynamespace</span>" <span style="COLOR: red">serviceBusIssuerName</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">owner</span>" <span style="COLOR: red">serviceBusIssuerSecret</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">xxxxxxxx</span>" <span style="COLOR: red">localHostName</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">mybox</span>"<span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">hostMappings</span><span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">add </span><span style="COLOR: red">targetHost</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">3389</span>" <span style="COLOR: blue">/&gt;
&lt;/</span><span style="COLOR: #a31515">hostMappings</span><span style="COLOR: blue">&gt;
&lt;/</span><span style="COLOR: #a31515">portBridge</span><span style="COLOR: blue">&gt;</span></pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
The <em>serviceBusNamespace</em> attribute takes your Service Bus namespace name,
and the <em>serviceBusIssuerSecret</em> the respective secret. The <em>serviceBusIssuerName</em> should
remain “owner” unless you know why you want to change it. If you don’t have an <em>AppFabric </em>account
you might not understand what I’m writing about: <a href="https://netservices.azure.com">Go
make one</a>.  
</p>
        <p>
The <em>localHostName</em> attribute is optional and when set, it’s the name that’s
being used to map “localhost” into your Service Bus namespace. By default the name
that’s being used is the good old Windows computer-name.
</p>
        <p>
The <em>hostMappings </em>section contains a list of hosts and rules for what you
want to project out to Service Bus. Mind that all inbound connections to the endpoints
generated from the host mappings section are protected by the Access Control service
and require a token that grants access to your namespace – which is already very different
from opening up a port in your firewall. If you open up port 3389 (Remote Desktop)
through your firewall and NAT, everyone can walk up to that port and try their password-guessing
skills. If you open up port 3389 via Port Bridge, you first need to get through the
Access Control gate before you can even get at the remote port. 
</p>
        <p>
New host mappings are added with the <em>add</em> element. You can add any host that
the machine running the Port Bridge service can “see” via the network. The <em>allowedPorts </em>and <em>allowedPipes</em> attributes
define with TCP ports and/or which local named pipes are accessible. Examples:
</p>
        <ul>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">3389</span>" <span style="COLOR: blue">/&gt; </span>project
the local machine into Service Bus and only allow Remote Desktop (3389) 
</li>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">3389,1433</span>" <span style="COLOR: blue">/&gt; </span>project
the local machine into Service Bus and allow Remote Desktop (3389) and SQL Server
TDS (1433) 
</li>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">*</span>" <span style="COLOR: blue">/&gt; </span>project
the local machine into Service Bus and only allow any TCP port connection 
</li>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPipes</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">sql/query</span>" <span style="COLOR: blue">/&gt; </span>project
the local machine into Service Bus and allow no TCP connections but all named pipe
connections to \.\pipes\sql\query 
</li>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">otherbox</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">1433</span>" <span style="COLOR: blue">/&gt; </span>project
the machine “otherbox” into Service Bus and allow SQL Server TDS connections via TCP 
</li>
        </ul>
        <p>
          <strong>Agent</strong>
        </p>
        <p>
The agent’s exe file is “PortBridgeAgent.exe” and is also both a console app and a
Windows Service. 
</p>
        <p>
The app.config file on the Agent side (PortBridgeAgent/app.config, PortBridgeAgent.exe.config
in the binaries folder) specifies which ports or pipes you want to project into the
Agent machine and whether and how you want to firewall these ports. The firewall rules
here are not interacting with your local firewall. This is an additional layer of
protection.
</p>
        <pre class="code">
          <span style="COLOR: blue"> &lt;</span>
          <span style="COLOR: #a31515">portBridgeAgent </span>
          <span style="COLOR: red">serviceBusNamespace</span>
          <span style="COLOR: blue">=</span>"<span style="COLOR: blue">mysolution</span>" <span style="COLOR: red">serviceBusIssuerName</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">owner</span>" <span style="COLOR: red">serviceBusIssuerSecret</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">xxxxxxxx</span>"<span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">portMappings</span><span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">port </span><span style="COLOR: red">localTcpPort</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">13389</span>" <span style="COLOR: red">targetHost</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">mymachine</span>" <span style="COLOR: red">remoteTcpPort</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">3389</span>"<span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">firewallRules</span><span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">rule </span><span style="COLOR: red">source</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">127.0.0.1</span>" <span style="COLOR: blue">/&gt;
&lt;</span><span style="COLOR: #a31515">rule </span><span style="COLOR: red">sourceRangeBegin</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">10.0.0.0</span>" <span style="COLOR: red">sourceRangeEnd</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">10.255.255.255</span>" <span style="COLOR: blue">/&gt;
&lt;/</span><span style="COLOR: #a31515">firewallRules</span><span style="COLOR: blue">&gt;
&lt;/</span><span style="COLOR: #a31515">port</span><span style="COLOR: blue">&gt;
&lt;/</span><span style="COLOR: #a31515">portMappings</span><span style="COLOR: blue">&gt;
&lt;/</span><span style="COLOR: #a31515">portBridgeAgent</span><span style="COLOR: blue">&gt;</span></pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
Again, the <em>serviceBusNamespace</em> attribute takes your Service Bus namespace
name, and the <em>serviceBusIssuerSecret</em> the respective secret. 
</p>
        <p>
The <em>portMappings</em> collection holds the individual ports or pipes you want
to bring onto the local machine. Shown above is a mapping of Remote Desktop (port
3389 on the machine with the computer name or <em>localHostName</em> ‘mymachine’)
to the local port 13389. Once Service and Agent are running, you can connect to the
agent machine on port 13389 using the Remote Desktop client – with PortBridge mapping
that to port 3389 on the remote box. 
</p>
        <p>
The <em>firewallRules</em> collection allows (un-)constraining the TCP clients that
may connect to the projected port. By default, only connections from the same machine
are permitted.
</p>
        <p>
For named pipes, the configuration is similar, even though there are no firewall rules
and named pipes are always constrained to local connectivity by a set of ACLs that
are applied to the pipe. Pipe names must be relative. Here’s how a named pipe projection
of a default SQL Server instance could look like:
</p>
        <p>
          <span style="COLOR: blue">     &lt;</span>
          <span style="COLOR: #a31515">port </span>
          <span style="COLOR: red">localPipe</span>
          <span style="COLOR: blue">=</span>"<span style="COLOR: blue">sql/remote</span>" <span style="COLOR: red">targetHost</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">mymachine</span>" <span style="COLOR: red">remotePipe</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">sql/query</span>"/<span style="COLOR: blue">&gt;</span></p>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
There’s more to write about this, but how about I let you take a look at the code
first. I’ve also included two setup projects that can easily install Agent and Service
as Windows Services. You obviously don’t have to use those. 
</p>
        <p>
          <em>[Updated archive (2010-06-10) fixing config issue:]</em>
        </p>
        <a href="http://vasters.com/clemensv/content/binary/PortBridge20100610.zip">PortBridge20100610.zip
(90.99 KB)</a>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3e35d8bd-b755-453f-8c63-1a57c570eb4c" />
      </body>
      <title>Port Bridge</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx</guid>
      <link>http://vasters.com/clemensv/2009/11/18/Port+Bridge.aspx</link>
      <pubDate>Wed, 18 Nov 2009 17:37:28 GMT</pubDate>
      <description>&lt;p&gt;
Building “hybrid” cloud applications where parts of an an app lives up in a cloud
infrastructure and other parts of the infrastructure live at a hosting site, or a
data center, or even in your house ought to be simple – especially in this day and
age of Web services. You create a Web service, make it accessible through your firewall
and NAT, and the the cloud-hosted app calls it. That’s as easy as it ought to be.
&lt;/p&gt;
&lt;p&gt;
Unfortunately it’s not always that easy. If the server sits behind an Internet connection
with dynamically assigned IP addresses, if the upstream ISP is blocking select ports,
if it’s not feasible to open up inbound firewall ports, or if you have no influence
over the infrastructure whatsoever, reaching an on-premise service from the cloud
(or anywhere else) is a difficult thing to do. For these scenarios (and others) our
team is building the &lt;em&gt;&lt;a href="http://msdn.microsoft.com/en-us/azure/netservices.aspx"&gt;Windows
Azure platform AppFabric&lt;/a&gt; Service Bus&lt;/em&gt; (friends call us just &lt;em&gt;Service Bus&lt;/em&gt;). 
&lt;/p&gt;
&lt;p&gt;
Now – the Service Bus and the client bits in the &lt;em&gt;Microsoft.ServiceBus.dll &lt;/em&gt;assembly
are great if you have services can can be readily hooked up into the Service Bus because
they’re built with WCF. For services that aren’t built with WCF, but are at least
using HTTP, I’ve &lt;a href="http://vasters.com/clemensv/PermaLink,guid,83edb04a-5696-401c-a919-8c1f379d130c.aspx"&gt;previously
shown a way&lt;/a&gt; to hook them into Service Bus and have also demoed an updated version
of that capability at Sun’s Java One. I’ll release an update for those bits tomorrow
after my talk at PDC09 – the version currently here on my blog (ironically) doesn’t
play well with SOAP and also doesn’t have rewrite capabilities for WSDL. The new version
does. 
&lt;/p&gt;
&lt;p&gt;
But what if your service isn’t a WCF service or doesn’t speak HTTP? What if it speaks
SMTP, SNMP, POP, IMAP, RDP, TDS, SSH, ETC? 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Introducing Port Bridge&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
“Port Bridge” – which is just a descriptive name for this code sample, not an attempt
at branding – is a point-to-point tunneling utility to help with these scenarios.
Port Bridge consists of two components, the “Port Bridge Service” and the “Port Bridge
Agent”. Here’s a picture:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/865a80e15ca0_D9A4/image_2.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/865a80e15ca0_D9A4/image_thumb.png" width=611 height=220&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The Agent’s job is to listen for and accept TCP or Named Pipe connections on a configurable
port or local pipe name. The Service’s job is to accept for incoming connections from
the Agent, establish a duplex channel with the Agent, and pump the data from the Agent
to the actual listening service – and vice versa. It’s actually quite simple. In the
picture above you see that the Service is configured to connect to a SQL Server listening
at the SQL Server default port 1433 and that the Agent – running on a different machine,
is listening on port 1433 as well, thus mapping the remote SQL Server onto the Agent
machine as if it ran there. You can (and I think of that as to be more common) map
the service on the Agent to any port you like – say higher up at 41433.
&lt;/p&gt;
&lt;p&gt;
In order to increase the responsiveness and throughput for protocols that are happy
to kill and reestablish connections such as HTTP does, “Port Bridge” is always multiplexing
concurrent traffic that’s flowing between two parties on the same logical socket.
When using Port Bridge to bridge to a remote HTTP proxy that the Service machine can
see, but the Agent machine can’t see (which turns out to be the at-home scenario that
this capability emerged from) there are very many and very short-lived connections
being tunneled through the channel. Creating a new Service Bus channel for each of
these connections is feasible – but not very efficient. Holding on to a connection
for an extended period of time and multiplexing traffic over it is also beneficial
in the Port Bridge case because it is using the Service Bus &lt;em&gt;Hybrid&lt;/em&gt; connection
mode by default. With &lt;em&gt;Hybrid&lt;/em&gt;, all connections are first established through
the Service Bus Relay and then our bits do a little “NAT dance” trying to figure out
whether there’s a way to connect both parties with a direct socket – if that works
the connection gets upgraded to the most direct connections in-flight. The probing,
handshake, and upgrade of the socket may take 2-20 seconds and there’s some degree
of luck involved to get that direct socket established on a very busy NAT – and thus
we want to maximize the use of that precious socket instead of throwing it away all
the time.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;That seems familiar?!&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
You may notice that &lt;a href="http://vasters.com/clemensv/PermaLink,guid,26dc5df1-8b8c-4f71-8765-8904e584505b.aspx"&gt;SocketShifter&lt;/a&gt; (built
by our friends at &lt;a href="http://www.aws.net/"&gt;AWS in the UK&lt;/a&gt;) is quite similar
to Port Bridge. Even though the timing of the respective releases may not suggest
it, Port Bridge is indeed Socketshifter’s older brother. Because we couldn’t make
up our mind on whether to release Port Bridge for a while, I had AWS take a look at
the service contract shown below and explained a few principles that I’m also explaining
here and they had a first version of Socketshifter running within a few hours. There’s
nothing wrong with having two variants of the same thing. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;How does it work?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Since I’m publishing this as a sample, I obviously need to spend a little time on
the “how”, even I’ll limit that here and will explain that in more detail in a future
post. At the heart of the app, the contract that’s used between the Agent and the
Service is a simple duplex WCF contract:
&lt;/p&gt;
&lt;pre class=code&gt;    [&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;(Namespace=&lt;span style="COLOR: #a31515"&gt;"n:"&lt;/span&gt;,
Name=&lt;span style="COLOR: #a31515"&gt;"idx"&lt;/span&gt;, CallbackContract=&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;IDataExchange&lt;/span&gt;),
SessionMode=&lt;span style="COLOR: #2b91af"&gt;SessionMode&lt;/span&gt;.Required)] &lt;span style="COLOR: blue"&gt;public
interface &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;IDataExchange &lt;/span&gt;{ [&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;(Action=&lt;span style="COLOR: #a31515"&gt;"c"&lt;/span&gt;,
IsOneWay = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;, IsInitiating=&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)] &lt;span style="COLOR: blue"&gt;void &lt;/span&gt;Connect(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;i);
[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;(Action = &lt;span style="COLOR: #a31515"&gt;"w"&lt;/span&gt;,
IsOneWay = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)] &lt;span style="COLOR: blue"&gt;void &lt;/span&gt;Write(&lt;span style="COLOR: #2b91af"&gt;TransferBuffer &lt;/span&gt;d);
[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;(Action = &lt;span style="COLOR: #a31515"&gt;"d"&lt;/span&gt;,
IsOneWay = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;, IsTerminating = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)] &lt;span style="COLOR: blue"&gt;void &lt;/span&gt;Disconnect();
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
There’s a way to establish a session, send data either way, and close the session.
The &lt;em&gt;TransferBuffer&lt;/em&gt; type is really just a trick to avoid extra buffer copies
during serialization for efficiency reasons. But that’s it. The rest of Port Bridge
is a set of queue-buffered streams and pumps to make the data packets flow smoothly
and to accept inbound sockets/pipes and dispatch them out to the proxied services.
What’s noteworthy is that Port Bridge doesn’t use WCF streaming, but sends data in
chunks – which allows for much better flow control and enables multiplexing.
&lt;/p&gt;
&lt;p&gt;
Now you might say &lt;em&gt;You are using a WCF ServiceContract?&lt;/em&gt;&amp;nbsp;&lt;em&gt;Isn’t that
using SOAP and doesn’t that cause ginormous overhead?&lt;/em&gt; No, it doesn’t. We’re using
the WCF binary encoder in session mode here. That’s about as efficient as you can
get it on the wire with serialized data. The per-frame SOAP overhead for net.tcp with
the binary encoder in session mode is in the order of 40-50 bytes per message because
of dictionary-based metadata compression. The binary encoder also isn’t doing any
base64 trickery but treats binary as binary – one byte is one byte. Port Bridge is
using a default frame size of 64K (which gets filled up in high-volume streaming cases
due to the built-in Nagling support) and so we’re looking at an overhead of far less
than 0.1%. That’s not shabby. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;How do I use it?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
This is a code sample and thus you’ll have to build it using Visual Studio 2008. You’ll
find three code projects: &lt;em&gt;PortBridge&lt;/em&gt; (the Service), &lt;em&gt;PortBridgeAgent&lt;/em&gt; (the
Agent), and the &lt;em&gt;Microsoft.Samples.ServiceBus.Connections&lt;/em&gt; assembly that contains
the bulk of the logic for Port Bridge. It’s mostly straightforward to embed the agent
side or the service side into other hosts and I’ll show that in a separate post. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Service&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The service’s exe file is “PortBridge.exe” and is both a console app and a Windows
Service. If the Windows Service isn’t registered, the app will always start as a console
app. If the Windows Service is registered (with the installer or with installutil.exe)
you can force console-mode with the –c command line option.
&lt;/p&gt;
&lt;p&gt;
The app.config file on the Service Side (PortBridge/app.config, PortBridge.exe.config
in the binaries folder) specifies what ports or named pipes you want to project into
Service Bus:
&lt;/p&gt;
&lt;pre class=code&gt;&lt;span style="COLOR: blue"&gt; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portBridge &lt;/span&gt;&lt;span style="COLOR: red"&gt;serviceBusNamespace&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mynamespace&lt;/span&gt;" &lt;span style="COLOR: red"&gt;serviceBusIssuerName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;owner&lt;/span&gt;" &lt;span style="COLOR: red"&gt;serviceBusIssuerSecret&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;xxxxxxxx&lt;/span&gt;" &lt;span style="COLOR: red"&gt;localHostName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mybox&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;hostMappings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;3389&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;hostMappings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portBridge&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
The &lt;em&gt;serviceBusNamespace&lt;/em&gt; attribute takes your Service Bus namespace name,
and the &lt;em&gt;serviceBusIssuerSecret&lt;/em&gt; the respective secret. The &lt;em&gt;serviceBusIssuerName&lt;/em&gt; should
remain “owner” unless you know why you want to change it. If you don’t have an &lt;em&gt;AppFabric &lt;/em&gt;account
you might not understand what I’m writing about: &lt;a href="https://netservices.azure.com"&gt;Go
make one&lt;/a&gt;.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;localHostName&lt;/em&gt; attribute is optional and when set, it’s the name that’s
being used to map “localhost” into your Service Bus namespace. By default the name
that’s being used is the good old Windows computer-name.
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;hostMappings &lt;/em&gt;section contains a list of hosts and rules for what you
want to project out to Service Bus. Mind that all inbound connections to the endpoints
generated from the host mappings section are protected by the Access Control service
and require a token that grants access to your namespace – which is already very different
from opening up a port in your firewall. If you open up port 3389 (Remote Desktop)
through your firewall and NAT, everyone can walk up to that port and try their password-guessing
skills. If you open up port 3389 via Port Bridge, you first need to get through the
Access Control gate before you can even get at the remote port. 
&lt;/p&gt;
&lt;p&gt;
New host mappings are added with the &lt;em&gt;add&lt;/em&gt; element. You can add any host that
the machine running the Port Bridge service can “see” via the network. The &lt;em&gt;allowedPorts &lt;/em&gt;and &lt;em&gt;allowedPipes&lt;/em&gt; attributes
define with TCP ports and/or which local named pipes are accessible. Examples:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;3389&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the local machine into Service Bus and only allow Remote Desktop (3389) 
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;3389,1433&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the local machine into Service Bus and allow Remote Desktop (3389) and SQL Server
TDS (1433) 
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;*&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the local machine into Service Bus and only allow any TCP port connection 
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPipes&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;sql/query&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the local machine into Service Bus and allow no TCP connections but all named pipe
connections to \.\pipes\sql\query 
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;otherbox&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;1433&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the machine “otherbox” into Service Bus and allow SQL Server TDS connections via TCP 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;Agent&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The agent’s exe file is “PortBridgeAgent.exe” and is also both a console app and a
Windows Service. 
&lt;/p&gt;
&lt;p&gt;
The app.config file on the Agent side (PortBridgeAgent/app.config, PortBridgeAgent.exe.config
in the binaries folder) specifies which ports or pipes you want to project into the
Agent machine and whether and how you want to firewall these ports. The firewall rules
here are not interacting with your local firewall. This is an additional layer of
protection.
&lt;/p&gt;
&lt;pre class=code&gt;&lt;span style="COLOR: blue"&gt; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portBridgeAgent &lt;/span&gt;&lt;span style="COLOR: red"&gt;serviceBusNamespace&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mysolution&lt;/span&gt;" &lt;span style="COLOR: red"&gt;serviceBusIssuerName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;owner&lt;/span&gt;" &lt;span style="COLOR: red"&gt;serviceBusIssuerSecret&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;xxxxxxxx&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portMappings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;port &lt;/span&gt;&lt;span style="COLOR: red"&gt;localTcpPort&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;13389&lt;/span&gt;" &lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mymachine&lt;/span&gt;" &lt;span style="COLOR: red"&gt;remoteTcpPort&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;3389&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;firewallRules&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;rule &lt;/span&gt;&lt;span style="COLOR: red"&gt;source&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;127.0.0.1&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;rule &lt;/span&gt;&lt;span style="COLOR: red"&gt;sourceRangeBegin&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;10.0.0.0&lt;/span&gt;" &lt;span style="COLOR: red"&gt;sourceRangeEnd&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;10.255.255.255&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;firewallRules&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;port&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portMappings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portBridgeAgent&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
Again, the &lt;em&gt;serviceBusNamespace&lt;/em&gt; attribute takes your Service Bus namespace
name, and the &lt;em&gt;serviceBusIssuerSecret&lt;/em&gt; the respective secret. 
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;portMappings&lt;/em&gt; collection holds the individual ports or pipes you want
to bring onto the local machine. Shown above is a mapping of Remote Desktop (port
3389 on the machine with the computer name or &lt;em&gt;localHostName&lt;/em&gt; ‘mymachine’)
to the local port 13389. Once Service and Agent are running, you can connect to the
agent machine on port 13389 using the Remote Desktop client – with PortBridge mapping
that to port 3389 on the remote box. 
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;firewallRules&lt;/em&gt; collection allows (un-)constraining the TCP clients that
may connect to the projected port. By default, only connections from the same machine
are permitted.
&lt;/p&gt;
&lt;p&gt;
For named pipes, the configuration is similar, even though there are no firewall rules
and named pipes are always constrained to local connectivity by a set of ACLs that
are applied to the pipe. Pipe names must be relative. Here’s how a named pipe projection
of a default SQL Server instance could look like:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;port &lt;/span&gt;&lt;span style="COLOR: red"&gt;localPipe&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;sql/remote&lt;/span&gt;" &lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mymachine&lt;/span&gt;" &lt;span style="COLOR: red"&gt;remotePipe&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;sql/query&lt;/span&gt;"/&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
There’s more to write about this, but how about I let you take a look at the code
first. I’ve also included two setup projects that can easily install Agent and Service
as Windows Services. You obviously don’t have to use those. 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;[Updated archive (2010-06-10) fixing config issue:]&lt;/em&gt;
&lt;/p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/PortBridge20100610.zip"&gt;PortBridge20100610.zip
(90.99 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3e35d8bd-b755-453f-8c63-1a57c570eb4c" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
      <category>Technology/ISB</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=26dc5df1-8b8c-4f71-8765-8904e584505b</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,26dc5df1-8b8c-4f71-8765-8904e584505b.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,26dc5df1-8b8c-4f71-8765-8904e584505b.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=26dc5df1-8b8c-4f71-8765-8904e584505b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Anyone using the .NET Service Bus should take a good look at the <a href="http://blogs.aws.net/atc/post/SocketShifter-Warping-the-Internet-Space-Time-Continuum-with-the-Azure-NET-Service-Bus.aspx">SocketShifter
project</a> started by Rob Blackwell and Richard Prodger from AWS in the UK. AWS stands
for <a href="http://www.aws.net">Active Web Solutions</a>, not for the "other" AWS.
The full project is up on <a href="http://socketshifter.codeplex.com/">Codeplex</a>.
</p>
        <p>
What makes SocketShifter significant is that it takes the network abstraction of SOAP,
WS-Addressing, and the Service Bus full circle and layers the very bottom of that
stack - plain TCP connections - as a virtualization on top of the the stack. In other
words: SocketShifter allows you to create full-fidelity, bi-directional socket connections
through the .NET Service Bus.
</p>
        <p>
We've created something very similar to SocketShifter last year (we're using
it for a few internal purposes), but haven't made it public so far. I'm glad that
the AWS folks built this, so that you get to play with it.   
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=26dc5df1-8b8c-4f71-8765-8904e584505b" />
      </body>
      <title>SocketShifter - Network virtualization over the .NET Service Bus</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,26dc5df1-8b8c-4f71-8765-8904e584505b.aspx</guid>
      <link>http://vasters.com/clemensv/2009/07/06/SocketShifter+Network+Virtualization+Over+The+NET+Service+Bus.aspx</link>
      <pubDate>Mon, 06 Jul 2009 16:06:48 GMT</pubDate>
      <description>&lt;p&gt;
Anyone using the .NET Service Bus should take a good look at the &lt;a href="http://blogs.aws.net/atc/post/SocketShifter-Warping-the-Internet-Space-Time-Continuum-with-the-Azure-NET-Service-Bus.aspx"&gt;SocketShifter
project&lt;/a&gt; started by Rob Blackwell and Richard Prodger from AWS in the UK. AWS stands
for &lt;a href="http://www.aws.net"&gt;Active Web Solutions&lt;/a&gt;, not for the "other" AWS.
The full project is up on &lt;a href="http://socketshifter.codeplex.com/"&gt;Codeplex&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
What makes SocketShifter significant is that it takes the network abstraction of SOAP,
WS-Addressing, and the Service Bus full circle and layers the very bottom of that
stack - plain TCP connections - as a virtualization on top of the the stack. In other
words: SocketShifter allows you to create full-fidelity, bi-directional socket connections
through the .NET Service Bus.
&lt;/p&gt;
&lt;p&gt;
We've created something very similar to SocketShifter last year&amp;nbsp;(we're using
it for a few internal purposes), but haven't made it public so far. I'm glad that
the AWS folks&amp;nbsp;built this, so that you get to play with it.&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=26dc5df1-8b8c-4f71-8765-8904e584505b" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,26dc5df1-8b8c-4f71-8765-8904e584505b.aspx</comments>
      <category>.NET Services</category>
      <category>Architecture</category>
      <category>Technology</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=b703725d-3e6a-4dbb-a613-890c31505fe8</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,b703725d-3e6a-4dbb-a613-890c31505fe8.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,b703725d-3e6a-4dbb-a613-890c31505fe8.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=b703725d-3e6a-4dbb-a613-890c31505fe8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In Parts <a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx">3</a> and <a href="http://vasters.com/clemensv/PermaLink,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx">4</a> of
this series I’ve explained the REST protocol for the .NET Service Bus Queue capability.
If that looked a little too complicated for your taste and you’d rather clean with
a simple API surface, here’s the API that you’ll prefer. 
</p>
        <p>
We’ve got two simple classes in the SDK (in the Microsoft.ServiceBus assembly/namespace)
that do the job. The <em>QueueManagementClient</em> allows you to create, renew and
delete queues in/from the .NET Service Bus namespace:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span><span style="COLOR: #0000ff">class</span> QueueManagementClient </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> QueueClient
CreateQueue(TransportClientEndpointBehavior credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:                                          Uri queueUri, QueuePolicy queuePolicy);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span><span style="COLOR: #0000ff">void</span> DeleteQueue(TransportClientEndpointBehavior
credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:                                   Uri queueUri);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> QueueClient
GetQueue(TransportClientEndpointBehavior credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:                                       Uri queueUri);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> QueuePolicy
GetQueuePolicy(TransportClientEndpointBehavior credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:                                             Uri queueUri);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> DateTime
RenewQueue(TransportClientEndpointBehavior credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:                                      Uri queueUri, TimeSpan requestedExpiration);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13: }</pre>
        </pre>
        <p>
The most striking difference between this API (and the underlying SOAP protocol for
which we still owe you some docs) and the REST API/Protocol is that there’s only a
single URI to deal with. The WS-Transfer aligned protocol to manage the policy, the
“Queue Transfer” protocol used to dequeue messages, and the “Enqueue” protocol to
add messages to the queue are all overlaid over the exact same URI.
</p>
        <p>
The only somewhat ugly element here is the <em>TransportClientEndpointBehavior</em> that’s
our awkwardly named credentials container. That class was meant to evolve into something
else and then we changed our mind at some point, which is how the baby got stuck with
that name. We’ll give that a prettier moniker in one of the next CTPs and as part
of an overhaul of the .NET Access Control integration into Service Bus.
</p>
        <p>
The function of the methods themselves should be quite obvious. You can create a queue
by applying a <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">policy</a>,
you can delete a queue, attach to an existing queue, get the latest queue policy,
and renew (extend the lifetime) of a queue. For completeness, here’s CreateQueue in
context:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: Uri queueUri = ServiceBusEnvironment.CreateServiceUri("<span style="COLOR: #8b0000">sb</span>",
solutionName, "<span style="COLOR: #8b0000">/MyQueue/</span>"); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: QueuePolicy queuePolicy = <span style="COLOR: #0000ff">new</span> QueuePolicy(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: queuePolicy.ExpirationInstant = DateTime.UtcNow + TimeSpan.FromHours(1);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: QueueClient client = QueueManagementClient.CreateQueue(credential, queueUri, queuePolicy);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: queuePolicy = client.GetPolicy(); <span style="COLOR: #008000">//
get effective policy</span></pre>
        </pre>
        <p>
The <em>QueueClient</em> class allows interaction with a Queue. QueueClient instances
cannot be created directly, but must be created via the QueueManagementClient factory.
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">sealed</span><span style="COLOR: #0000ff">class</span> QueueClient </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> DeleteLockedMessage(Message
message); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> DeleteQueue(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:     <span style="COLOR: #0000ff">public</span> DateTime
GetExpiration(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:     <span style="COLOR: #0000ff">public</span> QueuePolicy
GetPolicy(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:     <span style="COLOR: #0000ff">public</span> Message
PeekLock(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     <span style="COLOR: #0000ff">public</span> Message
PeekLock(TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:     <span style="COLOR: #0000ff">public</span> IEnumerable&lt;Message&gt;
PeekLockMultiple(<span style="COLOR: #0000ff">int</span> maxMessages); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     <span style="COLOR: #0000ff">public</span> IEnumerable&lt;Message&gt;
PeekLockMultiple(<span style="COLOR: #0000ff">int</span> maxMessages, TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> Purge(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> ReleaseLock(Message
message); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:     <span style="COLOR: #0000ff">public</span> DateTime
Renew(TimeSpan requestedExpiration); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:     <span style="COLOR: #0000ff">public</span> Message
Retrieve(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:     <span style="COLOR: #0000ff">public</span> Message
Retrieve(TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:     <span style="COLOR: #0000ff">public</span> IEnumerable&lt;Message&gt;
RetrieveMultiple(<span style="COLOR: #0000ff">int</span> maxMessages); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:     <span style="COLOR: #0000ff">public</span> IEnumerable&lt;Message&gt;
RetrieveMultiple(<span style="COLOR: #0000ff">int</span> maxMessages, TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> Send(Message
message, TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 19:     <span style="COLOR: #0000ff">public</span> RouterSubscriptionClient
SubscribeToRouter(RouterClient routerClient, TimeSpan requestedTimeout); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 20: }</pre>
        </pre>
        <p>
As you can tell, the class is – well – a queue client. It’s using WCF’s <em><a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.aspx">Message</a></em> class
as its message abstraction and supports sending messages into the queue, reading messages
off the queue in a destructive fashion (Retrieve), and reading messages off the queue
using the Peek/Lock pattern which provides resilience against message loss if the
message were to be lost in transfer or the receiver fumbled the message. What you’ll
also notice is that there are RetrieveMultiple and PeekLockMultiple variants of the
retrieval functions which allow for getting more data with fewer network roundtrips. 
</p>
        <p>
Again, there should be no surprises using the API. Here’s how you send:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: queueClient.Send(Message.CreateMessage(MessageVersion.Default, "<span style="COLOR: #8b0000">Hello</span>",
input), TimeSpan.MaxValue);</pre>
        </pre>
        <p>
and here’s how you do a destructive read:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: Message message = queueClient.Retrieve();</pre>
        </pre>
        <p>
and here’s how you use the Peek/Lock pattern:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: Message message = queueClient.PeekLock();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: <span style="COLOR: #0000ff">string</span> content
= message.GetBody&lt;<span style="COLOR: #0000ff">string</span>&gt;(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: queueClient.DeleteLockedMessage(message);
</pre>
        </pre>
        <p>
There are several examples in the SDK showing how to use the API for Queues. The OnewayQueueSender
and SoapHttpQueueSender samples are particularly interesting since they just use WCF
channels to enqueue, including all the bells and whistles you get from using a WCF
channel. Here’s how the OnewayQueueSender does it:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: ChannelFactory&lt;IOnewayChannel&gt; channelFactory = 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:      <span style="COLOR: #0000ff">new</span> ChannelFactory&lt;IOnewayChannel&gt;(<span style="COLOR: #0000ff">new</span> NetOnewayRelayBinding(), </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:                                         <span style="COLOR: #0000ff">new</span> EndpointAddress(queueUri)); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: channelFactory.Endpoint.Behaviors.Add(userNamePasswordServiceBusCredential);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: IOnewayChannel onewayChannel = channelFactory.CreateChannel();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: <span style="COLOR: #0000ff">string</span> input
= Console.ReadLine(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: onewayChannel.Hello(<span style="COLOR: #0000ff">new</span> HelloMessage(input)); </pre>
        </pre>
        <p>
The logical next question is: So why is the Queue not hooked up to a WCF listener?
Answer: That’s what we’ve got “buffered Routers” for. The queue very explicitly provides
a ‘pull’ model and the WCF listener would abstract that away and turn it into ‘push’.
Routers provide ‘push’ natively <em>and</em> they can embed a Queue. More on Routers
in the next set of posts in this series. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b703725d-3e6a-4dbb-a613-890c31505fe8" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers and Queues - Part 5: The Queue API for the rest of us</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,b703725d-3e6a-4dbb-a613-890c31505fe8.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/07/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+5+The+Queue+API+For+The+Rest+Of+Us.aspx</link>
      <pubDate>Tue, 07 Apr 2009 06:38:26 GMT</pubDate>
      <description>&lt;p&gt;
In Parts &lt;a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx"&gt;3&lt;/a&gt; and &lt;a href="http://vasters.com/clemensv/PermaLink,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx"&gt;4&lt;/a&gt; of
this series I’ve explained the REST protocol for the .NET Service Bus Queue capability.
If that looked a little too complicated for your taste and you’d rather clean with
a simple API surface, here’s the API that you’ll prefer. 
&lt;/p&gt;
&lt;p&gt;
We’ve got two simple classes in the SDK (in the Microsoft.ServiceBus assembly/namespace)
that do the job. The &lt;em&gt;QueueManagementClient&lt;/em&gt; allows you to create, renew and
delete queues in/from the .NET Service Bus namespace:
&lt;/p&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;  1: &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; QueueManagementClient &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 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; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueueClient
CreateQueue(TransportClientEndpointBehavior credential, &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:                                          Uri queueUri, QueuePolicy queuePolicy);
&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;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; DeleteQueue(TransportClientEndpointBehavior
credential, &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:                                   Uri queueUri);
&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; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueueClient
GetQueue(TransportClientEndpointBehavior credential, &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:                                       Uri queueUri);
&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: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueuePolicy
GetQueuePolicy(TransportClientEndpointBehavior credential, &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:                                             Uri queueUri);
&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;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; DateTime
RenewQueue(TransportClientEndpointBehavior credential, &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:                                      Uri queueUri, TimeSpan requestedExpiration);
&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&gt;
&lt;p&gt;
The most striking difference between this API (and the underlying SOAP protocol for
which we still owe you some docs) and the REST API/Protocol is that there’s only a
single URI to deal with. The WS-Transfer aligned protocol to manage the policy, the
“Queue Transfer” protocol used to dequeue messages, and the “Enqueue” protocol to
add messages to the queue are all overlaid over the exact same URI.
&lt;/p&gt;
&lt;p&gt;
The only somewhat ugly element here is the &lt;em&gt;TransportClientEndpointBehavior&lt;/em&gt; that’s
our awkwardly named credentials container. That class was meant to evolve into something
else and then we changed our mind at some point, which is how the baby got stuck with
that name. We’ll give that a prettier moniker in one of the next CTPs and as part
of an overhaul of the .NET Access Control integration into Service Bus.
&lt;/p&gt;
&lt;p&gt;
The function of the methods themselves should be quite obvious. You can create a queue
by applying a &lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;policy&lt;/a&gt;,
you can delete a queue, attach to an existing queue, get the latest queue policy,
and renew (extend the lifetime) of a queue. For completeness, here’s CreateQueue in
context:
&lt;/p&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;  1: Uri queueUri = ServiceBusEnvironment.CreateServiceUri("&lt;span style="COLOR: #8b0000"&gt;sb&lt;/span&gt;",
solutionName, "&lt;span style="COLOR: #8b0000"&gt;/MyQueue/&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;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: QueuePolicy queuePolicy = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; QueuePolicy(); &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: queuePolicy.ExpirationInstant = DateTime.UtcNow + TimeSpan.FromHours(1);
&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 client = QueueManagementClient.CreateQueue(credential, queueUri, queuePolicy);
&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: queuePolicy = client.GetPolicy(); &lt;span style="COLOR: #008000"&gt;//
get effective policy&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The &lt;em&gt;QueueClient&lt;/em&gt; class allows interaction with a Queue. QueueClient instances
cannot be created directly, but must be created via the QueueManagementClient factory.
&lt;/p&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;  1: &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; QueueClient &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 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; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; DeleteLockedMessage(Message
message); &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;void&lt;/span&gt; DeleteQueue(); &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;public&lt;/span&gt; DateTime
GetExpiration(); &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: #0000ff"&gt;public&lt;/span&gt; QueuePolicy
GetPolicy(); &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; Message
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;  8:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; Message
PeekLock(TimeSpan timeout); &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: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;Message&amp;gt;
PeekLockMultiple(&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; maxMessages); &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;public&lt;/span&gt; IEnumerable&amp;lt;Message&amp;gt;
PeekLockMultiple(&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; maxMessages, TimeSpan timeout); &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;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Purge(); &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;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; ReleaseLock(Message
message); &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;public&lt;/span&gt; DateTime
Renew(TimeSpan requestedExpiration); &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: #0000ff"&gt;public&lt;/span&gt; Message
Retrieve(); &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;public&lt;/span&gt; Message
Retrieve(TimeSpan timeout); &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;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;Message&amp;gt;
RetrieveMultiple(&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; maxMessages); &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: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;Message&amp;gt;
RetrieveMultiple(&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; maxMessages, TimeSpan timeout); &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;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Send(Message
message, TimeSpan timeout); &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;public&lt;/span&gt; RouterSubscriptionClient
SubscribeToRouter(RouterClient routerClient, TimeSpan requestedTimeout); &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&gt;
&lt;p&gt;
As you can tell, the class is – well – a queue client. It’s using WCF’s &lt;em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.aspx"&gt;Message&lt;/a&gt;&lt;/em&gt; class
as its message abstraction and supports sending messages into the queue, reading messages
off the queue in a destructive fashion (Retrieve), and reading messages off the queue
using the Peek/Lock pattern which provides resilience against message loss if the
message were to be lost in transfer or the receiver fumbled the message. What you’ll
also notice is that there are RetrieveMultiple and PeekLockMultiple variants of the
retrieval functions which allow for getting more data with fewer network roundtrips. 
&lt;/p&gt;
&lt;p&gt;
Again, there should be no surprises using the API. Here’s how you send:
&lt;/p&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;  1: queueClient.Send(Message.CreateMessage(MessageVersion.Default, "&lt;span style="COLOR: #8b0000"&gt;Hello&lt;/span&gt;",
input), TimeSpan.MaxValue);&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
and here’s how you do a destructive read:
&lt;/p&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;  1: Message message = queueClient.Retrieve();&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
and here’s how you use the Peek/Lock pattern:
&lt;/p&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;  1: Message message = queueClient.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;  2: &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; content
= message.GetBody&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&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: queueClient.DeleteLockedMessage(message);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
There are several examples in the SDK showing how to use the API for Queues. The OnewayQueueSender
and SoapHttpQueueSender samples are particularly interesting since they just use WCF
channels to enqueue, including all the bells and whistles you get from using a WCF
channel. Here’s how the OnewayQueueSender does it:
&lt;/p&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;  1: ChannelFactory&amp;lt;IOnewayChannel&amp;gt; channelFactory = 
&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;new&lt;/span&gt; ChannelFactory&amp;lt;IOnewayChannel&amp;gt;(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; NetOnewayRelayBinding(), &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;new&lt;/span&gt; EndpointAddress(queueUri)); &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: channelFactory.Endpoint.Behaviors.Add(userNamePasswordServiceBusCredential);
&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: IOnewayChannel onewayChannel = channelFactory.CreateChannel();
&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: #0000ff"&gt;string&lt;/span&gt; input
= Console.ReadLine(); &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: onewayChannel.Hello(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; HelloMessage(input)); &lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The logical next question is: So why is the Queue not hooked up to a WCF listener?
Answer: That’s what we’ve got “buffered Routers” for. The queue very explicitly provides
a ‘pull’ model and the WCF listener would abstract that away and turn it into ‘push’.
Routers provide ‘push’ natively &lt;em&gt;and&lt;/em&gt; they can embed a Queue. More on Routers
in the next set of posts in this series. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b703725d-3e6a-4dbb-a613-890c31505fe8" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,b703725d-3e6a-4dbb-a613-890c31505fe8.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=4aefc36e-4476-4543-9574-13727c8f615d</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=4aefc36e-4476-4543-9574-13727c8f615d</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
After I’ve gone through the dry facts of the REST Queue Protocol in <a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx">Part
3 of this series</a>, here’s some code to look at. The code snippets are ripped from
the HTTP Queue sample we’ve got in the .NET Services <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8d1d1d5e-1332-4186-b33f-26d053759e49&amp;displaylang=en">SDK</a> and
you can get the copy/paste ready code from there. 
</p>
        <p>
The most straightforward way to acquire the required hashed security token (<a href="http://vasters.com/clemensv/PermaLink,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx">see
my comments to Stefan Tilkov</a>) using HttpWebRequest looks like this:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">static</span><span style="COLOR: #0000ff">string</span> HttpGetAuthenticationToken(<span style="COLOR: #0000ff">string</span> username, <span style="COLOR: #0000ff">string</span> password) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:     <span style="COLOR: #0000ff">string</span> tokenUri
= <span style="COLOR: #0000ff">string</span>.Format("<span style="COLOR: #8b0000">https://{0}/issuetoken.aspx?u={1}&amp;p={2}</span>", </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:                                     ServiceBusEnvironment.DefaultIdentityHostName, 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:                                     username, Uri.EscapeDataString(password));
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:     HttpWebRequest tokenRequest = (HttpWebRequest)WebRequest.Create(tokenUri);
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     <span style="COLOR: #0000ff">using</span> (var
tokenResponse = tokenRequest.GetResponse()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:         <span style="COLOR: #0000ff">using</span> (var
tokenResponseStream = tokenResponse.GetResponseStream()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:         {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:             <span style="COLOR: #0000ff">byte</span>[]
tokenBody = <span style="COLOR: #0000ff">new</span><span style="COLOR: #0000ff">byte</span>[500]; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:             <span style="COLOR: #0000ff">int</span> tokenBodyLength
= tokenResponseStream.Read(tokenBody, 0, 500); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:             <span style="COLOR: #0000ff">return</span> Encoding.UTF8.GetString(tokenBody,
0, tokenBodyLength); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:         }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:     }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17: }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18: </pre>
        </pre>
        <p>
Once you’ve got the token, you need to pick a place in the Service Bus namespace.
We’ve got a built-in helper function in the SDK that sits on <em>ServiceBusEnvironment</em> and
which knows all the right incantations:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1:  Uri queueUri = ServiceBusEnvironment.CreateServiceUri(
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:                    Uri.UriSchemeHttps, 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:                    solutionName, 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:                    "<span style="COLOR: #8b0000">/MyHttpQueue/</span>"); </pre>
        </pre>
        <p>
Invoked in this way, the method yields the URI <strong>https://yourproject.<font color="#ff8040">servicebus.windows.net</font>/MyHttpQueue/</strong> so
there’s spectacularly little magic to it. The reason why we recommend that you use
the method in .NET applications is that we’ve broken everyone’s apps going from the
previous CTP to the current CTP due to the namespace restructuring and we’d like to
avoid doing that again as we improve the namespace story. I don’t foresee any further
change of the magnitude we had this time, however. 
</p>
        <p>
To create a new Queue, you first <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">create
a Queue policy</a> and then apply it to the Service Bus namespace name. We’ve got
a Queue Policy object in the SDK that I’ll use here to keep things short. I’m accepting
all the defaults that are spelled out in <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">Part
2 of the series</a>, but explicitly I’m setting the expiration to 1 hour. The Queue
Policy XSD schema in the the HTTP Queue sample’s <em>readme</em> document, by the
way. 
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: QueuePolicy queuePolicy = <span style="COLOR: #0000ff">new</span> QueuePolicy(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: queuePolicy.ExpirationInstant = DateTime.UtcNow + TimeSpan.FromHours(1);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: queueManageUri = HttpCreateQueue(token, queueUri, queuePolicy);</pre>
        </pre>
        <p>
The code for creating the Queue shouldn’t be very surprising. It’s a POST of an Atom
1.0 entry for which I’m using HttpWebRequest and the WCF 3.5 Syndication API. The
SDK sample is using a rather terse version of the ‘correct’ way of doing things. I’m
quoting the expanded variant from the Text140 sample that I showed at MIX’09:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> QueuePolicy
HttpCreateQueue(<span style="COLOR: #0000ff">string</span> token, Uri queueUri, QueuePolicy
policy, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:                                           <span style="COLOR: #0000ff">out</span> Uri
queueSelfUri, <span style="COLOR: #0000ff">out</span> Uri queueHeadUri) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:     HttpWebRequest webRequest;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:     HttpWebResponse webResponse;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:     queueSelfUri = <span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     queueHeadUri = <span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     <span style="COLOR: #008000">//
Create a new syndication item and add the queue policy as an extension</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     SyndicationItem syndicationItem = <span style="COLOR: #0000ff">new</span> SyndicationItem(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:     syndicationItem.ElementExtensions.Add(
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:         <span style="COLOR: #0000ff">new</span> SyndicationElementExtension("<span style="COLOR: #8b0000">QueuePolicy</span>", </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:                                         "<span style="COLOR: #8b0000">http://schemas.microsoft.com/ws/2007/08/connect</span>", </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:                                         policy));
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:     <span style="COLOR: #008000">//
create a new POST request and set the Content-Type to represent an Atom 1.0 entry</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18:     webRequest = HttpWebRequest.Create(queueUri) <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 19:     webRequest.ConnectionGroupName = "<span style="COLOR: #8b0000">queueclient</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 20:     webRequest.KeepAlive = <span style="COLOR: #0000ff">false</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 21:     webRequest.Method = "<span style="COLOR: #8b0000">POST</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 22:     webRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 23:     webRequest.ContentType = "<span style="COLOR: #8b0000">application/atom+xml;type=entry;charset=utf-8</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 24: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 25:     <span style="COLOR: #008000">//
write the item to the request stream</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 26:     <span style="COLOR: #0000ff">using</span> (var
requestStream = webRequest.GetRequestStream()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 27:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 28:         <span style="COLOR: #0000ff">using</span> (var
textWriter = <span style="COLOR: #0000ff">new</span> XmlTextWriter(requestStream,
Encoding.UTF8)) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 29:         {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 30:             syndicationItem.GetAtom10Formatter().WriteTo(textWriter);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 31:             textWriter.Flush();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 32:         }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 33:     }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 34: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 35:     <span style="COLOR: #008000">//
get the response</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 36:     <span style="COLOR: #0000ff">using</span> (webResponse
= webRequest.GetResponse() <span style="COLOR: #0000ff">as</span> HttpWebResponse) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 37:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 38:         <span style="COLOR: #0000ff">return</span> GetQueueInfoFromResponse(webResponse,
queueUri, <span style="COLOR: #0000ff">out</span> queueSelfUri, <span style="COLOR: #0000ff">out</span> queueHeadUri); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 39:     }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 40: }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 41: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 42: <span style="COLOR: #0000ff">static</span> QueuePolicy
GetQueueInfoFromResponse(HttpWebResponse webResponse, Uri queueUri, </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 43:                                                     <span style="COLOR: #0000ff">out</span> Uri
queueSelfUri, <span style="COLOR: #0000ff">out</span> Uri queueHeadUri) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 44: {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 45:     queueHeadUri = <span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 46:     queueSelfUri = <span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 47: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 48:     <span style="COLOR: #0000ff">if</span> (webResponse.ContentType.StartsWith("<span style="COLOR: #8b0000">application/atom+xml;type=entry</span>",
StringComparison.OrdinalIgnoreCase)) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 49:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 50:         Atom10ItemFormatter atomItemFormatter = <span style="COLOR: #0000ff">new</span> Atom10ItemFormatter(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 51:         <span style="COLOR: #0000ff">using</span> (var
responseReader = <span style="COLOR: #0000ff">new</span> XmlTextReader(webResponse.GetResponseStream())) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 52:         {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 53:             atomItemFormatter.ReadFrom(responseReader);
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 54:             <span style="COLOR: #008000">//
we found it. let's get the policy and the queue head URI</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 55:             <span style="COLOR: #0000ff">foreach</span> (SyndicationLink
queueSelfLink <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 56:                            from link <span style="COLOR: #0000ff">in</span> atomItemFormatter.Item.Links </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 57:                            where link.RelationshipType.Equals("<span style="COLOR: #8b0000">self</span>",
StringComparison.OrdinalIgnoreCase) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 58:                            select link)
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 59:             {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 60:                 queueSelfUri = queueSelfLink.Uri;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 61:                 <span style="COLOR: #0000ff">break</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 62:             }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 63: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 64:             <span style="COLOR: #0000ff">foreach</span> (SyndicationLink
queueHeadLink <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 65:                            from link <span style="COLOR: #0000ff">in</span> atomItemFormatter.Item.Links </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 66:                            where link.RelationshipType.Equals("<span style="COLOR: #8b0000">queuehead</span>",
StringComparison.OrdinalIgnoreCase) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 67:                            select link)
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 68:             {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 69:                 queueHeadUri = queueHeadLink.Uri;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 70:                 <span style="COLOR: #0000ff">break</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 71:             }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 72: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 73:             <span style="COLOR: #0000ff">return</span> atomItemFormatter.Item.ElementExtensions.ReadElementExtensions&lt;QueuePolicy&gt;( </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 74:                  "<span style="COLOR: #8b0000">QueuePolicy</span>", </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 75:                  "<span style="COLOR: #8b0000">http://schemas.microsoft.com/ws/2007/08/connect</span>").FirstOrDefault(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 76:         }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 77:     }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 78:     <span style="COLOR: #0000ff">else</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 79:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 80:         Atom10FeedFormatter atomFeedFormatter = <span style="COLOR: #0000ff">new</span> Atom10FeedFormatter(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 81:         <span style="COLOR: #0000ff">using</span> (var
responseReader = <span style="COLOR: #0000ff">new</span> XmlTextReader(webResponse.GetResponseStream())) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 82:         {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 83:             atomFeedFormatter.ReadFrom(responseReader);
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 84: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 85:             <span style="COLOR: #008000">//
look for an item whose alternate-link equals the desired queue URI. The alternate </span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 86:             <span style="COLOR: #008000">//
URI is the 'tail' endpoint by which the queue is mapped into the namespace. We are </span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 87:             <span style="COLOR: #008000">//
comparing Authority and Path since the scheme might be http or https and we want to
match</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 88:             <span style="COLOR: #008000">//
either.</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 89:             <span style="COLOR: #0000ff">foreach</span> (SyndicationItem
requestedItem <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 90:                          from item <span style="COLOR: #0000ff">in</span> atomFeedFormatter.Feed.Items </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 91:                          from link <span style="COLOR: #0000ff">in</span> item.Links </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 92:                          where 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 93:                            (link.RelationshipType.Equals("<span style="COLOR: #8b0000">alternate</span>",
StringComparison.OrdinalIgnoreCase) &amp;&amp; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 94:                             link.Uri.Authority.Equals(queueUri.Authority, StringComparison.OrdinalIgnoreCase) &amp;&amp;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 95:                             link.Uri.AbsolutePath.Equals(queueUri.AbsolutePath, StringComparison.OrdinalIgnoreCase)) ||
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 96:                            (link.RelationshipType.Equals("<span style="COLOR: #8b0000">self</span>",
StringComparison.OrdinalIgnoreCase) &amp;&amp; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 97:                             link.Uri.Equals(queueUri))
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 98:                          select item)
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 99:             {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">100:                 <span style="COLOR: #008000">//
we found it. let's get the policy and the queue head URI</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">101:                 <span style="COLOR: #0000ff">foreach</span> (SyndicationLink
queueSelfLink <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">102:                                from link <span style="COLOR: #0000ff">in</span> requestedItem.Links </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">103:                                where link.RelationshipType.Equals("<span style="COLOR: #8b0000">self</span>",
StringComparison.OrdinalIgnoreCase) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">104:                                select link)
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">105:                 {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">106:                     queueSelfUri = queueSelfLink.Uri;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">107:                     <span style="COLOR: #0000ff">break</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">108:                 }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">109: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">110:                 <span style="COLOR: #0000ff">foreach</span> (SyndicationLink
queueHeadLink <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">111:                                from link <span style="COLOR: #0000ff">in</span> requestedItem.Links </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">112:                                where link.RelationshipType.Equals("<span style="COLOR: #8b0000">queuehead</span>",
StringComparison.OrdinalIgnoreCase) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">113:                                select link)
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">114:                 {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">115:                     queueHeadUri = queueHeadLink.Uri;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">116:                     <span style="COLOR: #0000ff">break</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">117:                 }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">118: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">119:                 <span style="COLOR: #0000ff">return</span> requestedItem.ElementExtensions.ReadElementExtensions&lt;QueuePolicy&gt;( </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">120:                      "<span style="COLOR: #8b0000">QueuePolicy</span>", </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">121:                      "<span style="COLOR: #8b0000">http://schemas.microsoft.com/ws/2007/08/connect</span>").FirstOrDefault(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">122:             }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">123:         }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">124:     }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">125:     <span style="COLOR: #0000ff">return</span><span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">126: }</pre>
        </pre>
        <p>
The “magic” that isn’t straight up Atom Pub is in lines 10-15 above. I’m attaching
the policy object to the SyndicationItem abstraction that will be written out as an
Atom 1.0 entry. [I know that copy/paste is difficult using this format – I need to
clean up that expanded utility class and will post it in downloadable form within
the next few days]
</p>
        <p>
The method returns the effective policy that the Service Bus is using, and yields
the management URI for the queue where the Atom entry resides (self-link) as well
as the head of the queue as output arguments. The <em>queueUri</em> to which you applied
the entry has morphed into the Queue’s tail when the method returns successfully.
Having the Queue by its tail, submitting messages into it is very simple. Just do
a plain POST. Here we’re just writing a simple string from the local variable <em>input</em> as
the entity body and send it.
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #008000">//
send</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: HttpWebRequest sendRequest = HttpWebRequest.Create(queueUri) <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: sendRequest.Method = "<span style="COLOR: #8b0000">POST</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: sendRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: sendRequest.ContentType = "<span style="COLOR: #8b0000">text/plain;charset=utf-8</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: <span style="COLOR: #0000ff">using</span> (var
sendStream = sendRequest.GetRequestStream()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     <span style="COLOR: #0000ff">using</span> (var
writer = <span style="COLOR: #0000ff">new</span> StreamWriter(sendStream, Encoding.UTF8)) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:         writer.Write(input);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:         writer.Flush();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:     }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13: }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14: sendRequest.GetResponse().Close();</pre>
        </pre>
        <p>
For a simple destructive read, you use the ‘queue head’ URI and do a DELETE:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: HttpWebRequest dequeueRequest = 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:     HttpWebRequest.Create(queueHeadUri.AbsoluteUri+
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:                           "<span style="COLOR: #8b0000">?encoding=asreply&amp;maxmessages=1&amp;timeout=60</span>") <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: dequeueRequest.ConnectionGroupName = "<span style="COLOR: #8b0000">dequeue</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: dequeueRequest.Method = "<span style="COLOR: #8b0000">DELETE</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: dequeueRequest.ContentLength = 0;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: dequeueRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: <span style="COLOR: #0000ff">using</span> (HttpWebResponse
response = dequeueRequest.GetResponse() <span style="COLOR: #0000ff">as</span> HttpWebResponse) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     <span style="COLOR: #0000ff">if</span> (response.StatusCode
== HttpStatusCode.OK) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:         <span style="COLOR: #0000ff">using</span> (var
responseBody = response.GetResponseStream()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:         {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:             <span style="COLOR: #0000ff">using</span> (var
responseReader = <span style="COLOR: #0000ff">new</span> StreamReader(responseBody,
Encoding.UTF8)) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:             {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:                 <span style="COLOR: #0000ff">string</span> data
= responseReader.ReadToEnd(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:                 Console.WriteLine(data);
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18:             }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 19:         }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 20:     }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 21: }</pre>
        </pre>
        <p>
For a peek/lock read where you first lock the message and then delete the lock when
you want to keep the message, you do a POST on the head and remember the <em>X-MS-Message-Lock</em> header
value:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: HttpWebRequest dequeueRequest = 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:      HttpWebRequest.Create(queueHeadUri.AbsoluteUri+
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:                            "<span style="COLOR: #8b0000">?encoding=asreply&amp;maxmessages=1&amp;timeout=60</span>") <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: dequeueRequest.ConnectionGroupName = "<span style="COLOR: #8b0000">dequeue</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: dequeueRequest.Method = "<span style="COLOR: #8b0000">POST</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: dequeueRequest.ContentLength = 0;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: dequeueRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: <span style="COLOR: #0000ff">using</span> (HttpWebResponse
response = dequeueRequest.GetResponse() <span style="COLOR: #0000ff">as</span> HttpWebResponse) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     <span style="COLOR: #0000ff">if</span> (response.StatusCode
== HttpStatusCode.OK) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:         lockUri = <span style="COLOR: #0000ff">new</span> Uri(response.Headers["<span style="COLOR: #8b0000">X-MS-Message-Lock</span>"]); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:         <span style="COLOR: #0000ff">using</span> (var
responseBody = response.GetResponseStream()) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:         {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:             <span style="COLOR: #0000ff">using</span> (var
responseReader = <span style="COLOR: #0000ff">new</span> StreamReader(responseBody,
Encoding.UTF8)) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:             {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:                 <span style="COLOR: #0000ff">string</span> data
= responseReader.ReadToEnd(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18:                 Console.WriteLine(data);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 19:             }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 20:         }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 21:     }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 22: }</pre>
        </pre>
        <p>
If you decide to keep the message (i.e. your app didn’t puke processing it), you DELETE
the lock, otherwise you do a PUT. The code is practically the same except for the
method so I’ll just quote DELETE:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: HttpWebRequest deleteLockedMessageRequest = HttpWebRequest.Create(lockUri) <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: deleteLockedMessageRequest.ConnectionGroupName = "<span style="COLOR: #8b0000">lock</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: deleteLockedMessageRequest.Method = "<span style="COLOR: #8b0000">DELETE</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: deleteLockedMessageRequest.KeepAlive=<span style="COLOR: #0000ff">false</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: deleteLockedMessageRequest.ContentLength = 0;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: deleteLockedMessageRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: deleteLockedMessageRequest.ContentLength = 0;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: deleteLockedMessageRequest.GetResponse().Close();</pre>
        </pre>
        <p>
That’s it. Create, Enqueue, Destructive Read, Peek/Lock Read, and .. oh .. yes.. forgot
Delete the Queue. Take the snippet above and swap out the lockUri for the queueSelfUri.
Done.  
</p>
        <p>
Ah, yes, and please … don’t blame me for HTTP or HttpWebRequest or Clemens’ demo coding
style requiring too many lines of code. I could have applied a bit of code-compression
here, but I’m intentionally trying not to abstract away too much of the protocol here.
I’m generally with you, though. The guys putting together the <a href="http://msdn.microsoft.com/wcf/rest">WCF
REST Starter Kit</a> are working on making code like that shrink.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=4aefc36e-4476-4543-9574-13727c8f615d" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers and Queues - Part 4: The REST Queue Protocol in Code Snippets</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/07/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+4+The+REST+Queue+Protocol+In+Code+Snippets.aspx</link>
      <pubDate>Tue, 07 Apr 2009 05:40:58 GMT</pubDate>
      <description>&lt;p&gt;
After I’ve gone through the dry facts of the REST Queue Protocol in &lt;a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx"&gt;Part
3 of this series&lt;/a&gt;, here’s some code to look at. The code snippets are ripped from
the HTTP Queue sample we’ve got in the .NET Services &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8d1d1d5e-1332-4186-b33f-26d053759e49&amp;amp;displaylang=en"&gt;SDK&lt;/a&gt; and
you can get the copy/paste ready code from there. 
&lt;/p&gt;
&lt;p&gt;
The most straightforward way to acquire the required hashed security token (&lt;a href="http://vasters.com/clemensv/PermaLink,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx"&gt;see
my comments to Stefan Tilkov&lt;/a&gt;) using HttpWebRequest looks like this:
&lt;/p&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;  1: &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; HttpGetAuthenticationToken(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; username, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; password) &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 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;string&lt;/span&gt; tokenUri
= &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Format("&lt;span style="COLOR: #8b0000"&gt;https://{0}/issuetoken.aspx?u={1}&amp;amp;p={2}&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:                                     ServiceBusEnvironment.DefaultIdentityHostName, 
&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:                                     username, Uri.EscapeDataString(password));
&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:     HttpWebRequest tokenRequest = (HttpWebRequest)WebRequest.Create(tokenUri);
&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: #0000ff"&gt;using&lt;/span&gt; (var
tokenResponse = tokenRequest.GetResponse()) &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: #0000ff"&gt;using&lt;/span&gt; (var
tokenResponseStream = tokenResponse.GetResponseStream()) &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;span style="COLOR: #0000ff"&gt;byte&lt;/span&gt;[]
tokenBody = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;byte&lt;/span&gt;[500]; &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;int&lt;/span&gt; tokenBodyLength
= tokenResponseStream.Read(tokenBody, 0, 500); &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: #0000ff"&gt;return&lt;/span&gt; Encoding.UTF8.GetString(tokenBody,
0, tokenBodyLength); &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:     }
&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;/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&gt;
&lt;p&gt;
Once you’ve got the token, you need to pick a place in the Service Bus namespace.
We’ve got a built-in helper function in the SDK that sits on &lt;em&gt;ServiceBusEnvironment&lt;/em&gt; and
which knows all the right incantations:
&lt;/p&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;  1:  Uri queueUri = ServiceBusEnvironment.CreateServiceUri(
&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:                    Uri.UriSchemeHttps, 
&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:                    solutionName, 
&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: #8b0000"&gt;/MyHttpQueue/&lt;/span&gt;"); &lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
Invoked in this way, the method yields the URI &lt;strong&gt;https://yourproject.&lt;font color=#ff8040&gt;servicebus.windows.net&lt;/font&gt;/MyHttpQueue/&lt;/strong&gt; so
there’s spectacularly little magic to it. The reason why we recommend that you use
the method in .NET applications is that we’ve broken everyone’s apps going from the
previous CTP to the current CTP due to the namespace restructuring and we’d like to
avoid doing that again as we improve the namespace story. I don’t foresee any further
change of the magnitude we had this time, however. 
&lt;/p&gt;
&lt;p&gt;
To create a new Queue, you first &lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;create
a Queue policy&lt;/a&gt; and then apply it to the Service Bus namespace name. We’ve got
a Queue Policy object in the SDK that I’ll use here to keep things short. I’m accepting
all the defaults that are spelled out in &lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;Part
2 of the series&lt;/a&gt;, but explicitly I’m setting the expiration to 1 hour. The Queue
Policy XSD schema in the the HTTP Queue sample’s &lt;em&gt;readme&lt;/em&gt; document, by the
way. 
&lt;/p&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;  1: QueuePolicy queuePolicy = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; QueuePolicy(); &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: queuePolicy.ExpirationInstant = DateTime.UtcNow + TimeSpan.FromHours(1);
&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: queueManageUri = HttpCreateQueue(token, queueUri, queuePolicy);&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The code for creating the Queue shouldn’t be very surprising. It’s a POST of an Atom
1.0 entry for which I’m using HttpWebRequest and the WCF 3.5 Syndication API. The
SDK sample is using a rather terse version of the ‘correct’ way of doing things. I’m
quoting the expanded variant from the Text140 sample that I showed at MIX’09:
&lt;/p&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;  1: &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueuePolicy
HttpCreateQueue(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; token, Uri queueUri, QueuePolicy
policy, &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;out&lt;/span&gt; Uri
queueSelfUri, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; Uri queueHeadUri) &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:     HttpWebRequest webRequest;
&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:     HttpWebResponse webResponse;
&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:     queueSelfUri = &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;  8:     queueHeadUri = &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;  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;//
Create a new syndication item and add the queue policy as an extension&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:     SyndicationItem syndicationItem = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; SyndicationItem(); &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:     syndicationItem.ElementExtensions.Add(
&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;new&lt;/span&gt; SyndicationElementExtension("&lt;span style="COLOR: #8b0000"&gt;QueuePolicy&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:                                         "&lt;span style="COLOR: #8b0000"&gt;http://schemas.microsoft.com/ws/2007/08/connect&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:                                         policy));
&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 a new POST request and set the Content-Type to represent an Atom 1.0 entry&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:     webRequest = HttpWebRequest.Create(queueUri) &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &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:     webRequest.ConnectionGroupName = "&lt;span style="COLOR: #8b0000"&gt;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; 20:     webRequest.KeepAlive = &lt;span style="COLOR: #0000ff"&gt;false&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:     webRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;POST&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:     webRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &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:     webRequest.ContentType = "&lt;span style="COLOR: #8b0000"&gt;application/atom+xml;type=entry;charset=utf-8&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: 
&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;span style="COLOR: #008000"&gt;//
write the item to the request stream&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;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
requestStream = webRequest.GetRequestStream()) &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: #0000ff"&gt;using&lt;/span&gt; (var
textWriter = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlTextWriter(requestStream,
Encoding.UTF8)) &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:             syndicationItem.GetAtom10Formatter().WriteTo(textWriter);
&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:             textWriter.Flush();
&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;/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;//
get the response&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;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (webResponse
= webRequest.GetResponse() &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebResponse) &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: #0000ff"&gt;return&lt;/span&gt; GetQueueInfoFromResponse(webResponse,
queueUri, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; queueSelfUri, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; queueHeadUri); &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;/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;/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;static&lt;/span&gt; QueuePolicy
GetQueueInfoFromResponse(HttpWebResponse webResponse, Uri queueUri, &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: #0000ff"&gt;out&lt;/span&gt; Uri
queueSelfUri, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; Uri queueHeadUri) &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;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 45:     queueHeadUri = &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; 46:     queueSelfUri = &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; 47: 
&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:     &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (webResponse.ContentType.StartsWith("&lt;span style="COLOR: #8b0000"&gt;application/atom+xml;type=entry&lt;/span&gt;",
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; 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:         Atom10ItemFormatter atomItemFormatter = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Atom10ItemFormatter(); &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:         &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseReader = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlTextReader(webResponse.GetResponseStream())) &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:             atomItemFormatter.ReadFrom(responseReader);
&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;span style="COLOR: #008000"&gt;//
we found it. let's get the policy and the queue head URI&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; 55:             &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationLink
queueSelfLink &lt;span style="COLOR: #0000ff"&gt;in&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:                            from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; atomItemFormatter.Item.Links &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:                            where link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;self&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &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:                            select link)
&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:             {
&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:                 queueSelfUri = queueSelfLink.Uri;
&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: #0000ff"&gt;break&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:             }
&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: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationLink
queueHeadLink &lt;span style="COLOR: #0000ff"&gt;in&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:                            from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; atomItemFormatter.Item.Links &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:                            where link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;queuehead&lt;/span&gt;",
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; 67:                            select link)
&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:             {
&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:                 queueHeadUri = queueHeadLink.Uri;
&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:                 &lt;span style="COLOR: #0000ff"&gt;break&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; 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;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 73:             &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; atomItemFormatter.Item.ElementExtensions.ReadElementExtensions&amp;lt;QueuePolicy&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; 74:                  "&lt;span style="COLOR: #8b0000"&gt;QueuePolicy&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; 75:                  "&lt;span style="COLOR: #8b0000"&gt;http://schemas.microsoft.com/ws/2007/08/connect&lt;/span&gt;").FirstOrDefault(); &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:         }
&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;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; 79:     {
&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:         Atom10FeedFormatter atomFeedFormatter = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Atom10FeedFormatter(); &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: #0000ff"&gt;using&lt;/span&gt; (var
responseReader = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlTextReader(webResponse.GetResponseStream())) &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:         {
&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:             atomFeedFormatter.ReadFrom(responseReader);
&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;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 85:             &lt;span style="COLOR: #008000"&gt;//
look for an item whose alternate-link equals the desired queue URI. The alternate &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; 86:             &lt;span style="COLOR: #008000"&gt;//
URI is the 'tail' endpoint by which the queue is mapped into the namespace. We are &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; 87:             &lt;span style="COLOR: #008000"&gt;//
comparing Authority and Path since the scheme might be http or https and we want to
match&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; 88:             &lt;span style="COLOR: #008000"&gt;//
either.&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; 89:             &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationItem
requestedItem &lt;span style="COLOR: #0000ff"&gt;in&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; 90:                          from item &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; atomFeedFormatter.Feed.Items &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:                          from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; item.Links &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:                          where 
&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:                            (link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;alternate&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &amp;amp;&amp;amp; &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:                             link.Uri.Authority.Equals(queueUri.Authority, StringComparison.OrdinalIgnoreCase) &amp;amp;&amp;amp;
&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:                             link.Uri.AbsolutePath.Equals(queueUri.AbsolutePath, StringComparison.OrdinalIgnoreCase)) ||
&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:                            (link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;self&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &amp;amp;&amp;amp; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 97:                             link.Uri.Equals(queueUri))
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 98:                          select item)
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 99:             {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;100:                 &lt;span style="COLOR: #008000"&gt;//
we found it. let's get the policy and the queue head URI&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;101:                 &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationLink
queueSelfLink &lt;span style="COLOR: #0000ff"&gt;in&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;102:                                from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; requestedItem.Links &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;103:                                where link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;self&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;104:                                select link)
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;105:                 {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;106:                     queueSelfUri = queueSelfLink.Uri;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;107:                     &lt;span style="COLOR: #0000ff"&gt;break&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;108:                 }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;109: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;110:                 &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationLink
queueHeadLink &lt;span style="COLOR: #0000ff"&gt;in&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;111:                                from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; requestedItem.Links &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;112:                                where link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;queuehead&lt;/span&gt;",
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;113:                                select link)
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;114:                 {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;115:                     queueHeadUri = queueHeadLink.Uri;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;116:                     &lt;span style="COLOR: #0000ff"&gt;break&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;117:                 }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;118: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;119:                 &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; requestedItem.ElementExtensions.ReadElementExtensions&amp;lt;QueuePolicy&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;120:                      "&lt;span style="COLOR: #8b0000"&gt;QueuePolicy&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;121:                      "&lt;span style="COLOR: #8b0000"&gt;http://schemas.microsoft.com/ws/2007/08/connect&lt;/span&gt;").FirstOrDefault(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;122:             }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;123:         }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;124:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;125:     &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &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;126: }&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The “magic” that isn’t straight up Atom Pub is in lines 10-15 above. I’m attaching
the policy object to the SyndicationItem abstraction that will be written out as an
Atom 1.0 entry. [I know that copy/paste is difficult using this format – I need to
clean up that expanded utility class and will post it in downloadable form within
the next few days]
&lt;/p&gt;
&lt;p&gt;
The method returns the effective policy that the Service Bus is using, and yields
the management URI for the queue where the Atom entry resides (self-link) as well
as the head of the queue as output arguments. The &lt;em&gt;queueUri&lt;/em&gt; to which you applied
the entry has morphed into the Queue’s tail when the method returns successfully.
Having the Queue by its tail, submitting messages into it is very simple. Just do
a plain POST. Here we’re just writing a simple string from the local variable &lt;em&gt;input&lt;/em&gt; as
the entity body and send it.
&lt;/p&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;  1: &lt;span style="COLOR: #008000"&gt;//
send&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: HttpWebRequest sendRequest = HttpWebRequest.Create(queueUri) &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &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: sendRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;POST&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: sendRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &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: sendRequest.ContentType = "&lt;span style="COLOR: #8b0000"&gt;text/plain;charset=utf-8&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;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
sendStream = sendRequest.GetRequestStream()) &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: #0000ff"&gt;using&lt;/span&gt; (var
writer = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; StreamWriter(sendStream, Encoding.UTF8)) &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:         writer.Write(input);
&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:         writer.Flush();
&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;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 14: sendRequest.GetResponse().Close();&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
For a simple destructive read, you use the ‘queue head’ URI and do a DELETE:
&lt;/p&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;  1: HttpWebRequest dequeueRequest = 
&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:     HttpWebRequest.Create(queueHeadUri.AbsoluteUri+
&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: #8b0000"&gt;?encoding=asreply&amp;amp;maxmessages=1&amp;amp;timeout=60&lt;/span&gt;") &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &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: dequeueRequest.ConnectionGroupName = "&lt;span style="COLOR: #8b0000"&gt;dequeue&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: dequeueRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;DELETE&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: dequeueRequest.ContentLength = 0;
&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: dequeueRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &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: #0000ff"&gt;using&lt;/span&gt; (HttpWebResponse
response = dequeueRequest.GetResponse() &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebResponse) &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: #0000ff"&gt;if&lt;/span&gt; (response.StatusCode
== HttpStatusCode.OK) &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;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseBody = response.GetResponseStream()) &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: #0000ff"&gt;using&lt;/span&gt; (var
responseReader = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; StreamReader(responseBody,
Encoding.UTF8)) &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:                 &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; data
= responseReader.ReadToEnd(); &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(data);
&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;/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;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
For a peek/lock read where you first lock the message and then delete the lock when
you want to keep the message, you do a POST on the head and remember the &lt;em&gt;X-MS-Message-Lock&lt;/em&gt; header
value:
&lt;/p&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;  1: HttpWebRequest dequeueRequest = 
&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:      HttpWebRequest.Create(queueHeadUri.AbsoluteUri+
&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: #8b0000"&gt;?encoding=asreply&amp;amp;maxmessages=1&amp;amp;timeout=60&lt;/span&gt;") &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &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: dequeueRequest.ConnectionGroupName = "&lt;span style="COLOR: #8b0000"&gt;dequeue&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: dequeueRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;POST&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: dequeueRequest.ContentLength = 0;
&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: dequeueRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &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: #0000ff"&gt;using&lt;/span&gt; (HttpWebResponse
response = dequeueRequest.GetResponse() &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebResponse) &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: #0000ff"&gt;if&lt;/span&gt; (response.StatusCode
== HttpStatusCode.OK) &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:         lockUri = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Uri(response.Headers["&lt;span style="COLOR: #8b0000"&gt;X-MS-Message-Lock&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;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseBody = response.GetResponseStream()) &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;using&lt;/span&gt; (var
responseReader = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; StreamReader(responseBody,
Encoding.UTF8)) &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: #0000ff"&gt;string&lt;/span&gt; data
= responseReader.ReadToEnd(); &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(data);
&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:     }
&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&gt;
&lt;p&gt;
If you decide to keep the message (i.e. your app didn’t puke processing it), you DELETE
the lock, otherwise you do a PUT. The code is practically the same except for the
method so I’ll just quote DELETE:
&lt;/p&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;  1: HttpWebRequest deleteLockedMessageRequest = HttpWebRequest.Create(lockUri) &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &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: deleteLockedMessageRequest.ConnectionGroupName = "&lt;span style="COLOR: #8b0000"&gt;lock&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: deleteLockedMessageRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;DELETE&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: deleteLockedMessageRequest.KeepAlive=&lt;span style="COLOR: #0000ff"&gt;false&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: deleteLockedMessageRequest.ContentLength = 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;  6: deleteLockedMessageRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &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: deleteLockedMessageRequest.ContentLength = 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;  8: deleteLockedMessageRequest.GetResponse().Close();&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
That’s it. Create, Enqueue, Destructive Read, Peek/Lock Read, and .. oh .. yes.. forgot
Delete the Queue. Take the snippet above and swap out the lockUri for the queueSelfUri.
Done.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Ah, yes, and please … don’t blame me for HTTP or HttpWebRequest or Clemens’ demo coding
style requiring too many lines of code. I could have applied a bit of code-compression
here, but I’m intentionally trying not to abstract away too much of the protocol here.
I’m generally with you, though. The guys putting together the &lt;a href="http://msdn.microsoft.com/wcf/rest"&gt;WCF
REST Starter Kit&lt;/a&gt; are working on making code like that shrink.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=4aefc36e-4476-4543-9574-13727c8f615d" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=19e938fc-e6ec-42df-96d9-e2f6a31f7399</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=19e938fc-e6ec-42df-96d9-e2f6a31f7399</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.innoq.com/blog/st/2009/04/net_services_rest_queue_protoc.html">Stefan
Tilkov has several interesting remarks</a> regarding our <a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx">.NET
Service Bus REST Queue Protocol</a> that are worth addressing.
</p>
        <p>
          <font color="#0080c0">
            <em>      Putting a password in the
URI to get an identity token seems to expose information unnecessarily</em>
          </font>
        </p>
        <p>
That’s an area where we know that we’re going to change the protocol. We’ve already
labeled that protocol as temporary in the documentation for the PDC CTP and we didn’t
get all the pieces in the .NET Access Control service together, yet. Since it’s a
HTTPS call, the data doesn’t get exposed on the wire, though. 
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">Queue
creation seems fine, even though I feel a little uneasy about wrapping this in an
Atom entry </font>
          </em>
        </p>
        <p>
Using Atom 1.0 and the Atom Publishing Protocol as the framework for managing the
namespace is very intentional - for several reasons. First of all, it’s a standardized
protocol for managing generic lists and the elements in those lists. With that we
have a stable and accepted protocol framework and there’s plenty of tooling and framework
support around it. That’s worth something. All we need to do is to add some simple
extensions – the policies – on top of that stack. Beats having to define, version,
and maintain a whole protocol.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">On
the other hand, Atom seems reasonable considering you get an Atom feed from the queue’s
“parent” resource </font>
          </em>
        </p>
        <p>
That’s what I mean. All sorts of tools know how to navigate and display Atom.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">Very
nice to see the use of link/rel to get to the detailed Queue URIs; it would be even
better if the rel values themselves were URIs in an MS namespace </font>
          </em>
        </p>
        <p>
          <br />
I don’t see much potential for collision here and I would find it odd to have something
as simple “self” and “alternate” and then add some unsightly QName for my rel expressions.
Simple is good.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">Using
“alternate” for the tail seems strange </font>
          </em>
        </p>
        <p>
“self” refers to the location where the Atom &lt;entry&gt; resides. “alternate” is
what the entry points to. Since the Queue gets mapped into the namespace by “sticking
its tail out”, the choice of the alternate link is the simplest possible mapping I
could think of.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">“The
queue’s tail endpoint accepts requests with any HTTP Content-Type and any HTTP method
except GET, HEAD, and OPTIONS.” The tail does not accept GET. Why not? Can’t think
of a reason. Also, I don’t get why any method is allowed. It seems to me a POST/PUT
combination or an idempotent POST variant would be the way to go. </font>
          </em>
        </p>
        <p>
The way to look at this is that the Queue’s tail is acting on behalf of the receiver/resource
that’ll eventually pick up and process the messages. POST, PUT, DELETE, and BOOYAH
are all operations that cleanly map to processing operations and can often be delivered
asynchronously with a 202 receipt reply. GET and HEAD don’t make much sense when executed
in an asynchronous fashion without getting a reply that’s backed by a response for
the receiver. OPTIONS is simply reserved for future use. 
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">“DELETE
performing a destructive read” – huh? What happens if I don’t get back a response?
How can I retry (as I can’t tell whether I get the same or a different message)? Maybe
it’s intended to be used only if you don’t care about losing messages. </font>
          </em>
        </p>
        <p>
DELETE is indeed the dequeue operation variant that you’d use if you are ok with occasional
message loss and want to trade transfer reliability for fewer roundtrips. 
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">The
POST lock/delete approach, on the other hand, is very nice. Maybe it should be made
idempotent, again e.g. using POE </font>
          </em>
        </p>
        <p>
POST lock/delete is the dequeue variant where you are doing the trade the other way
around. More reliability bought with an extra roundtrip. In my view, idempotent access
to individual messages isn’t much of a practical priority for a competing consumer
queue. You’ll get a message or a set of messages to look at under a lock and if you
walk away from the message(s), those messages pop back into the queue for someone
else to look at. There are obviously scenarios where you want to look at a message
sequence in other ways than an ordered queue where you can only get at messages as
they appear on the head of the sequence – direct message access and per-message idempotent
access matter in those scenarios and we’re looking to give you a capability of that
sort in a different kind of messaging primitive.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">“The
Delete request is sent without any entity body and MUST have a Content-Length header
that is set to zero (0)”; although my immediate reaction was to question whether DELETE
ever carries a body, the HTTP spec indeed doesn’t say anything about this </font>
          </em>
        </p>
        <p>
One of the great things about working here is that there are all sorts of interesting
people around. I’ve discussed the use of DELETE and whether you can provide an entity
body in either direction with <a href="http://en.wikipedia.org/wiki/Henrik_Frystyk_Nielsen">Henrik
Frystyk Nielsen</a>, who works as an architect on the WCF team and is one of the co-authors
of HTTP 1.1. Henrik’s stance is that all operations allow entity-bodies unless it’s
explicitly forbidden in the spec. I don’t have a better authority to talk to.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">“The
DELETE and POST operation have a set of options that are expressed as query parameters
appended to the queue’s head URI” - the wording is worse than the actual approach.</font>
          </em>
        </p>
        <p>
I’m sorry that my writing is so clumsy ;-)
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=19e938fc-e6ec-42df-96d9-e2f6a31f7399" />
      </body>
      <title>The .NET Service Bus REST protocol for Queues - Some comments, some answers</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/07/The+NET+Service+Bus+REST+Protocol+For+Queues+Some+Comments+Some+Answers.aspx</link>
      <pubDate>Tue, 07 Apr 2009 04:14:16 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.innoq.com/blog/st/2009/04/net_services_rest_queue_protoc.html"&gt;Stefan
Tilkov has several interesting remarks&lt;/a&gt; regarding our &lt;a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx"&gt;.NET
Service Bus REST Queue Protocol&lt;/a&gt; that are worth addressing.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Putting a password in the URI
to get an identity token seems to expose information unnecessarily&lt;/em&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
That’s an area where we know that we’re going to change the protocol. We’ve already
labeled that protocol as temporary in the documentation for the PDC CTP and we didn’t
get all the pieces in the .NET Access Control service together, yet. Since it’s a
HTTPS call, the data doesn’t get exposed on the wire, though. 
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;Queue
creation seems fine, even though I feel a little uneasy about wrapping this in an
Atom entry &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
Using Atom 1.0 and the Atom Publishing Protocol as the framework for managing the
namespace is very intentional - for several reasons. First of all, it’s a standardized
protocol for managing generic lists and the elements in those lists. With that we
have a stable and accepted protocol framework and there’s plenty of tooling and framework
support around it. That’s worth something. All we need to do is to add some simple
extensions – the policies – on top of that stack. Beats having to define, version,
and maintain a whole protocol.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;On
the other hand, Atom seems reasonable considering you get an Atom feed from the queue’s
“parent” resource &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
That’s what I mean. All sorts of tools know how to navigate and display Atom.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;Very
nice to see the use of link/rel to get to the detailed Queue URIs; it would be even
better if the rel values themselves were URIs in an MS namespace &lt;/font&gt;&lt;/em&gt; 
&lt;p&gt;
&lt;br&gt;
I don’t see much potential for collision here and I would find it odd to have something
as simple “self” and “alternate” and then add some unsightly QName for my rel expressions.
Simple is good.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;Using
“alternate” for the tail seems strange &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
“self” refers to the location where the Atom &amp;lt;entry&amp;gt; resides. “alternate” is
what the entry points to. Since the Queue gets mapped into the namespace by “sticking
its tail out”, the choice of the alternate link is the simplest possible mapping I
could think of.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;“The
queue’s tail endpoint accepts requests with any HTTP Content-Type and any HTTP method
except GET, HEAD, and OPTIONS.” The tail does not accept GET. Why not? Can’t think
of a reason. Also, I don’t get why any method is allowed. It seems to me a POST/PUT
combination or an idempotent POST variant would be the way to go. &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
The way to look at this is that the Queue’s tail is acting on behalf of the receiver/resource
that’ll eventually pick up and process the messages. POST, PUT, DELETE, and BOOYAH
are all operations that cleanly map to processing operations and can often be delivered
asynchronously with a 202 receipt reply. GET and HEAD don’t make much sense when executed
in an asynchronous fashion without getting a reply that’s backed by a response for
the receiver. OPTIONS is simply reserved for future use. 
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;“DELETE
performing a destructive read” – huh? What happens if I don’t get back a response?
How can I retry (as I can’t tell whether I get the same or a different message)? Maybe
it’s intended to be used only if you don’t care about losing messages. &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
DELETE is indeed the dequeue operation variant that you’d use if you are ok with occasional
message loss and want to trade transfer reliability for fewer roundtrips. 
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;The
POST lock/delete approach, on the other hand, is very nice. Maybe it should be made
idempotent, again e.g. using POE &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
POST lock/delete is the dequeue variant where you are doing the trade the other way
around. More reliability bought with an extra roundtrip. In my view, idempotent access
to individual messages isn’t much of a practical priority for a competing consumer
queue. You’ll get a message or a set of messages to look at under a lock and if you
walk away from the message(s), those messages pop back into the queue for someone
else to look at. There are obviously scenarios where you want to look at a message
sequence in other ways than an ordered queue where you can only get at messages as
they appear on the head of the sequence – direct message access and per-message idempotent
access matter in those scenarios and we’re looking to give you a capability of that
sort in a different kind of messaging primitive.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;“The
Delete request is sent without any entity body and MUST have a Content-Length header
that is set to zero (0)”; although my immediate reaction was to question whether DELETE
ever carries a body, the HTTP spec indeed doesn’t say anything about this &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
One of the great things about working here is that there are all sorts of interesting
people around. I’ve discussed the use of DELETE and whether you can provide an entity
body in either direction with &lt;a href="http://en.wikipedia.org/wiki/Henrik_Frystyk_Nielsen"&gt;Henrik
Frystyk Nielsen&lt;/a&gt;, who works as an architect on the WCF team and is one of the co-authors
of HTTP 1.1. Henrik’s stance is that all operations allow entity-bodies unless it’s
explicitly forbidden in the spec. I don’t have a better authority to talk to.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;“The
DELETE and POST operation have a set of options that are expressed as query parameters
appended to the queue’s head URI” - the wording is worse than the actual approach.&lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
I’m sorry that my writing is so clumsy ;-)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=19e938fc-e6ec-42df-96d9-e2f6a31f7399" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=83edb04a-5696-401c-a919-8c1f379d130c</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,83edb04a-5696-401c-a919-8c1f379d130c.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,83edb04a-5696-401c-a919-8c1f379d130c.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=83edb04a-5696-401c-a919-8c1f379d130c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:2fa07bff-113a-425e-98ba-b07fc54b0584" class="wlWriterEditableSmartContent">
          <p>
.NET Service Bus Reverse Web Proxy: <a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/NETServicesMarch2009CTPHostaPublicWebs_9AB2/ServiceBusReverseWebProxy.zip">Click
here to download the source</a></p>
        </div>
        <p>
          <strong>
          </strong>
        </p>
        <p>
          <a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/NETServicesMarch2009CTPHostaPublicWebs_9AB2/image_2.png">
            <img style="BORDER-RIGHT-WIDTH: 0px; MARGIN: 10px 20px 10px 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" border="0" alt="image" align="left" src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/NETServicesMarch2009CTPHostaPublicWebs_9AB2/image_thumb.png" width="383" height="500" />
          </a>
        </p>
        <p style="MARGIN-TOP: 5px">
Using the application/service built from the sample linked at the top of this post
you can <strong>host</strong> a <strong>publicly discoverable and accessible website</strong> or
Web service <strong>from your Windows notebook</strong> or desktop machine from within
most network environments <strong>without</strong> having to <strong>open up a port
on the firewall</strong>, mapping a port on your NAT, or using some type of dynamic
DNS service to make the site discoverable. All those essential connectivity features
are provided by the .NET Service Bus and with the help of the included sample code.
</p>
        <p style="MARGIN-TOP: 5px">
I’m intentionally not bundling this up as a conveniently installable binary along
with a nice configuration UI – that’s not my role here. If <strong>you</strong> want
to grab the code and make it part of a cool personal media sharing app, provide external
access to a departmental enterprise app, put a prototype out there for a client to
play with, host a web service you want to show off, or or provide an installable version
with a nice configuration UI – go ahead. 
</p>
        <p style="MARGIN-TOP: 5px">
The attached sample application/service has two key capabilities that I’ve repeatedly
been asked for:
</p>
        <p style="MARGIN-TOP: 5px">
a) It is a <strong>reverse web proxy</strong> that can run either as a console application
or as a Windows (NT-) service. The reverse web proxy can sit in front of any web server
and forward requests to it. I’ve tested this only with IIS as the backend, but I don’t
see a reason why this shouldn’t work with Apache or the Web Server built into some
J2EE application server. 
</p>
        <p style="MARGIN-TOP: 5px">
b) It is a scripting <strong>policy host</strong> that projects the <em>crossdomain.xml</em> and <em>ClientPolicyAccess.xml</em> files
required by <strong>Adobe Flash</strong> and <strong>Microsoft Silverlight</strong> into
the root of a .NET Services namespace, permitting cross-domain script access from
Flash and Silverlight for all endpoints hosted within the namespace. You can easily
adjust the code in the sample to restrict access to particular resources within the
namespace.
</p>
        <p style="MARGIN-TOP: 5px">
The fundamental architecture is illustrated in the picture. The web application that
you want to project out to the public internet sits on some web server on your machine.
“Your machine” may be a desktop machine at home or at work or a notebook in a hotel
lobby or an airport on WiFi. As long as you’ve got line-of-sight to the .NET Service
Bus and the TCP ports 828 and 818 are available for outbound traffic, you’re good.
The reverse web proxy app will map any local HTTP server to a name in the .NET Service
Bus and forward the traffic between the .NET Service Bus and the HTTP server. The
client (any web browser, but also any HTTP Web Service client) will talk to the .NET
Service Bus at the given name, the traffic flows to the reverse proxy on your machine
and from there to the HTTP server.
</p>
        <p style="MARGIN-TOP: 5px">
I’m hosting (for a few days) a sample <a href="http://www.dasblog.info">dasBlog</a> site
instance at <a title="http://clemensv6.servicebus.windows.net/dasblog/" href="http://clemensv6.servicebus.windows.net/dasblog/">http://clemensv6.servicebus.windows.net/dasblog/</a>.
The hosting machine for that blog is one of my personal machines. It’s got a local
network address assigned by DHCP, it’s not listed in any NAT mappings, and it’s local
Firewall isn’t even open for inbound HTTP traffic.  
</p>
        <p style="MARGIN-TOP: 5px">
          <strong>How to install, build, and run</strong>
        </p>
        <p style="MARGIN-TOP: 5px">
As a prerequisite you will need three things:
</p>
        <ol>
          <li>
            <div style="MARGIN-TOP: 5px">Visual Studio 2008 SP1 with the .NET Framework 3.5 SP1.
</div>
          </li>
          <li>
            <div style="MARGIN-TOP: 5px">A .NET Services project account. The quickest route is
to go to <a href="http://portal.ex.azure.microsoft.com">http://portal.ex.azure.microsoft.com</a> and
click “Sign up”. The approval/provisioning is pretty much instantaneous (plus 20 seconds
for the provisioning to run through) once you provide your Windows Live ID. No more
access codes.
</div>
          </li>
          <li>
            <div style="MARGIN-TOP: 5px">The .NET Services SDK for the March 2009 CTP. <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;displaylang=en">Click
here to get it</a>.
</div>
          </li>
        </ol>
        <p style="MARGIN-TOP: 5px">
Unpack the files, and open <em>ServiceBusReverseWebProxy.sln</em> with Visual Studio
2008. In the ServiceBusReverseWebProxy project, find the <strong>app.config</strong> file
and open it. Here’s where you need to put your project name and password and where
you map your sites:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">&lt;?</span>xml
version="1.0" encoding="utf-8" <span style="COLOR: #0000ff">?&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: <span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">configuration</span><span style="COLOR: #0000ff">&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:     <span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">configSections</span><span style="COLOR: #0000ff">&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:         <span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">section</span><span style="COLOR: #ff0000">name</span>=<span style="COLOR: #0000ff">"reverseWebProxy"</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:                  <span style="COLOR: #ff0000">type</span>=<span style="COLOR: #0000ff">"Microsoft.Samples.ServiceBusReverseWebProxy.ReverseWebProxySection,
ServiceBusReverseWebProxy"</span><span style="COLOR: #0000ff">/&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:     <span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">configSections</span><span style="COLOR: #0000ff">&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:     <span style="COLOR: #008000">&lt;!--
Add your .NET Services project account information here --&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     <span style="COLOR: #008000">&lt;!--
Create a project at http://portal.ex.azure.microsoft.com/ --&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:     <span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">reverseWebProxy</span><span style="COLOR: #ff0000">netServicesProjectName</span>=<span style="COLOR: #0000ff">"!!myproject!!"</span><span style="COLOR: #ff0000">netServicesProjectPassword</span>=<span style="COLOR: #0000ff">"!!mypassword!!"</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:                      <span style="COLOR: #ff0000">enableSilverlightPolicy</span>=<span style="COLOR: #0000ff">"true"</span><span style="COLOR: #0000ff">&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     <span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">pathMappings</span><span style="COLOR: #0000ff">&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:       <span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">add</span><span style="COLOR: #ff0000">namespacePath</span>=<span style="COLOR: #0000ff">"mysite"</span><span style="COLOR: #ff0000">localUri</span>=<span style="COLOR: #0000ff">"http://localhost/mysite/"</span><span style="COLOR: #0000ff">/&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:     <span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">pathMappings</span><span style="COLOR: #0000ff">&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:   <span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">reverseWebProxy</span><span style="COLOR: #0000ff">&gt;</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15: <span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">configuration</span><span style="COLOR: #0000ff">&gt;</span></pre>
        </pre>
        <p>
Put your .NET Services project/solution name into the <em>netServicesProjectName</em> and
the password into <em>netServicesProjectPassword</em>. 
</p>
        <p>
Then pick a local HTTP server or site and give it a name in your .NET Service Bus
namespace. That mapping is done in the <em>&lt;pathMappings&gt;</em> section. There
are a few things that are important to note here:
</p>
        <ol>
          <li>
If your project name were ‘<strong>clemensv6</strong>’ and you map some local URI
to the namespacePath ‘<strong>dasBlog</strong>’, the resulting .NET Service Bus URI
would be <a title="http://clemensv6.servicebus.windows.net/dasblog/" href="http://clemensv6.servicebus.windows.net/dasblog/">http://<strong>clemensv6</strong>.servicebus.windows.net/<strong>dasblog</strong>/</a>. 
</li>
          <li>
The web application should only emit relative paths for links or, otherwise, should
have a way to specify the external host address for links. That means that the web
application needs to be able to deal with the presence of a reverse proxy. There is
no content-level URL rewriter in this sample that would make any corrections to HTML
or XML that’s handed upstream. DasBlog allows you to specify the blog site address
as some external address and therefore satisfies that requirements. 
</li>
          <li>
Redirects and any other HTTP responses that emit the HTTP ‘Location’ header or any
other HTTP headers where URIs are returned are rewritten to map the internal view
to the external view. 
</li>
          <li>
If you set <em>enableSilverlightPolicy</em> to <em>true</em>, there will be <em>crossdomain.xml</em> and <em>ClientPolicyAccess.xml</em> endpoints
projected into the root of your project’s namespace, ie. <a title="http://clemensv6.servicebus.windows.net/dasblog/" href="http://clemensv6.servicebus.windows.net/crossdomain.xml">http://clemensv6.servicebus.windows.net/crossdomain.xml</a><strong></strong></li>
        </ol>
        <p>
Build. Run. 
</p>
        <p>
By default, the ServiceBusReverseWebProxy.exe application will simply run as a console
application. If you use <strong>installutil –i ServiceBusReverseWebProxy.exe</strong> the
application will be installed as a Windows Service. The default identity that it is
installed under is ‘NETWORK SERVICE’. In restricted networks with constrained IPSec
policies (such as the Microsoft Corporate Network), you may have to use a user account
instead. You may also have to use some special Firewall-gateway software such as the
ISA Firewall client to allow for outbound access to ports 828 and 818. 
</p>
        <p>
The actual application code isn’t really all that complicated. The ‘beef’ is in <strong>ReverseWebProxy.cs</strong>.
What might be surprising here is that this class doesn’t use the WCF Service Model,
but is using naked WCF channels for the upstream traffic to .NET Services and it’s
using HttpWebRequest for the downstream traffic to the local Web Server. The reason
for using channels is that the app is never doing any processing on the messages,
so the channel model is the most straightforward and efficient way. The reason for
using HttpWebRequest is that you can’t suppress auto-redirects on a WCF HTTP client.
Since the stack needs to be completely transparent to redirects so that it’s the browser
client up on top that gets redirected instead of someone on the way, I simply couldn’t
use a WCF channel downstream. Seems to be one of these edge cases that the WCF team
downstairs didn’t think anyone would ever need.
</p>
        <p>
Let me know whether and how this works for you. Share the code, improve it, re-blog,
let me know. @clemensv on Twitter, same name @microsoft.com for email.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=83edb04a-5696-401c-a919-8c1f379d130c" />
      </body>
      <title>.NET Services March 2009 CTP: Host a Public Website At The Kitchen Table or from a Coffee Shop! No Kidding.</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,83edb04a-5696-401c-a919-8c1f379d130c.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/05/NET+Services+March+2009+CTP+Host+A+Public+Website+At+The+Kitchen+Table+Or+From+A+Coffee+Shop+No+Kidding.aspx</link>
      <pubDate>Sun, 05 Apr 2009 19:41:36 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:2fa07bff-113a-425e-98ba-b07fc54b0584 class=wlWriterEditableSmartContent&gt;
&lt;p&gt;
.NET Service Bus Reverse Web Proxy: &lt;a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/NETServicesMarch2009CTPHostaPublicWebs_9AB2/ServiceBusReverseWebProxy.zip"&gt;Click
here to download the source&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/NETServicesMarch2009CTPHostaPublicWebs_9AB2/image_2.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; MARGIN: 10px 20px 10px 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image align=left src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/NETServicesMarch2009CTPHostaPublicWebs_9AB2/image_thumb.png" width=383 height=500&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
Using the application/service built from the sample linked at the top of this post
you can &lt;strong&gt;host&lt;/strong&gt; a &lt;strong&gt;publicly discoverable and accessible website&lt;/strong&gt; or
Web service &lt;strong&gt;from your Windows notebook&lt;/strong&gt; or desktop machine from within
most network environments &lt;strong&gt;without&lt;/strong&gt; having to &lt;strong&gt;open up a port
on the firewall&lt;/strong&gt;, mapping a port on your NAT, or using some type of dynamic
DNS service to make the site discoverable. All those essential connectivity features
are provided by the .NET Service Bus and with the help of the included sample code.
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
I’m intentionally not bundling this up as a conveniently installable binary along
with a nice configuration UI – that’s not my role here. If &lt;strong&gt;you&lt;/strong&gt; want
to grab the code and make it part of a cool personal media sharing app, provide external
access to a departmental enterprise app, put a prototype out there for a client to
play with, host a web service you want to show off, or or provide an installable version
with a nice configuration UI – go ahead. 
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
The attached sample application/service has two key capabilities that I’ve repeatedly
been asked for:
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
a) It is a &lt;strong&gt;reverse web proxy&lt;/strong&gt; that can run either as a console application
or as a Windows (NT-) service. The reverse web proxy can sit in front of any web server
and forward requests to it. I’ve tested this only with IIS as the backend, but I don’t
see a reason why this shouldn’t work with Apache or the Web Server built into some
J2EE application server. 
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
b) It is a scripting &lt;strong&gt;policy host&lt;/strong&gt; that projects the &lt;em&gt;crossdomain.xml&lt;/em&gt; and &lt;em&gt;ClientPolicyAccess.xml&lt;/em&gt; files
required by &lt;strong&gt;Adobe Flash&lt;/strong&gt; and &lt;strong&gt;Microsoft Silverlight&lt;/strong&gt; into
the root of a .NET Services namespace, permitting cross-domain script access from
Flash and Silverlight for all endpoints hosted within the namespace. You can easily
adjust the code in the sample to restrict access to particular resources within the
namespace.
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
The fundamental architecture is illustrated in the picture. The web application that
you want to project out to the public internet sits on some web server on your machine.
“Your machine” may be a desktop machine at home or at work or a notebook in a hotel
lobby or an airport on WiFi. As long as you’ve got line-of-sight to the .NET Service
Bus and the TCP ports 828 and 818 are available for outbound traffic, you’re good.
The reverse web proxy app will map any local HTTP server to a name in the .NET Service
Bus and forward the traffic between the .NET Service Bus and the HTTP server. The
client (any web browser, but also any HTTP Web Service client) will talk to the .NET
Service Bus at the given name, the traffic flows to the reverse proxy on your machine
and from there to the HTTP server.
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
I’m hosting (for a few days) a sample &lt;a href="http://www.dasblog.info"&gt;dasBlog&lt;/a&gt; site
instance at &lt;a title=http://clemensv6.servicebus.windows.net/dasblog/ href="http://clemensv6.servicebus.windows.net/dasblog/"&gt;http://clemensv6.servicebus.windows.net/dasblog/&lt;/a&gt;.
The hosting machine for that blog is one of my personal machines. It’s got a local
network address assigned by DHCP, it’s not listed in any NAT mappings, and it’s local
Firewall isn’t even open for inbound HTTP traffic.&amp;nbsp; 
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
&lt;strong&gt;How to install, build, and run&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
As a prerequisite you will need three things:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div style="MARGIN-TOP: 5px"&gt;Visual Studio 2008 SP1 with the .NET Framework 3.5 SP1.
&lt;/div&gt;
&lt;li&gt;
&lt;div style="MARGIN-TOP: 5px"&gt;A .NET Services project account. The quickest route is
to go to &lt;a href="http://portal.ex.azure.microsoft.com"&gt;http://portal.ex.azure.microsoft.com&lt;/a&gt; and
click “Sign up”. The approval/provisioning is pretty much instantaneous (plus 20 seconds
for the provisioning to run through) once you provide your Windows Live ID. No more
access codes.
&lt;/div&gt;
&lt;li&gt;
&lt;div style="MARGIN-TOP: 5px"&gt;The .NET Services SDK for the March 2009 CTP. &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;amp;displaylang=en"&gt;Click
here to get it&lt;/a&gt;.
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="MARGIN-TOP: 5px"&gt;
Unpack the files, and open &lt;em&gt;ServiceBusReverseWebProxy.sln&lt;/em&gt; with Visual Studio
2008. In the ServiceBusReverseWebProxy project, find the &lt;strong&gt;app.config&lt;/strong&gt; file
and open it. Here’s where you need to put your project name and password and where
you map your sites:
&lt;/p&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;  1: &lt;span style="COLOR: #0000ff"&gt;&amp;lt;?&lt;/span&gt;xml
version="1.0" encoding="utf-8" &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;configuration&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;configSections&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;section&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="COLOR: #0000ff"&gt;"reverseWebProxy"&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: #ff0000"&gt;type&lt;/span&gt;=&lt;span style="COLOR: #0000ff"&gt;"Microsoft.Samples.ServiceBusReverseWebProxy.ReverseWebProxySection,
ServiceBusReverseWebProxy"&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;  6:     &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;configSections&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;  7:     &lt;span style="COLOR: #008000"&gt;&amp;lt;!--
Add your .NET Services project account information here --&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;  8:     &lt;span style="COLOR: #008000"&gt;&amp;lt;!--
Create a project at http://portal.ex.azure.microsoft.com/ --&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;  9:     &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;reverseWebProxy&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;netServicesProjectName&lt;/span&gt;=&lt;span style="COLOR: #0000ff"&gt;"!!myproject!!"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;netServicesProjectPassword&lt;/span&gt;=&lt;span style="COLOR: #0000ff"&gt;"!!mypassword!!"&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: #ff0000"&gt;enableSilverlightPolicy&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; 11:     &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;pathMappings&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; 12:       &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;namespacePath&lt;/span&gt;=&lt;span style="COLOR: #0000ff"&gt;"mysite"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;localUri&lt;/span&gt;=&lt;span style="COLOR: #0000ff"&gt;"http://localhost/mysite/"&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; 13:     &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;pathMappings&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; 14:   &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;reverseWebProxy&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; 15: &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
Put your .NET Services project/solution name into the &lt;em&gt;netServicesProjectName&lt;/em&gt; and
the password into &lt;em&gt;netServicesProjectPassword&lt;/em&gt;. 
&lt;/p&gt;
&lt;p&gt;
Then pick a local HTTP server or site and give it a name in your .NET Service Bus
namespace. That mapping is done in the &lt;em&gt;&amp;lt;pathMappings&amp;gt;&lt;/em&gt; section. There
are a few things that are important to note here:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
If your project name were ‘&lt;strong&gt;clemensv6&lt;/strong&gt;’ and you map some local URI
to the namespacePath ‘&lt;strong&gt;dasBlog&lt;/strong&gt;’, the resulting .NET Service Bus URI
would be &lt;a title=http://clemensv6.servicebus.windows.net/dasblog/ href="http://clemensv6.servicebus.windows.net/dasblog/"&gt;http://&lt;strong&gt;clemensv6&lt;/strong&gt;.servicebus.windows.net/&lt;strong&gt;dasblog&lt;/strong&gt;/&lt;/a&gt;. 
&lt;li&gt;
The web application should only emit relative paths for links or, otherwise, should
have a way to specify the external host address for links. That means that the web
application needs to be able to deal with the presence of a reverse proxy. There is
no content-level URL rewriter in this sample that would make any corrections to HTML
or XML that’s handed upstream. DasBlog allows you to specify the blog site address
as some external address and therefore satisfies that requirements. 
&lt;li&gt;
Redirects and any other HTTP responses that emit the HTTP ‘Location’ header or any
other HTTP headers where URIs are returned are rewritten to map the internal view
to the external view. 
&lt;li&gt;
If you set &lt;em&gt;enableSilverlightPolicy&lt;/em&gt; to &lt;em&gt;true&lt;/em&gt;, there will be &lt;em&gt;crossdomain.xml&lt;/em&gt; and &lt;em&gt;ClientPolicyAccess.xml&lt;/em&gt; endpoints
projected into the root of your project’s namespace, ie. &lt;a title=http://clemensv6.servicebus.windows.net/dasblog/ href="http://clemensv6.servicebus.windows.net/crossdomain.xml"&gt;http://clemensv6.servicebus.windows.net/crossdomain.xml&lt;/a&gt;&lt;strong&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Build. Run. 
&lt;/p&gt;
&lt;p&gt;
By default, the ServiceBusReverseWebProxy.exe application will simply run as a console
application. If you use &lt;strong&gt;installutil –i ServiceBusReverseWebProxy.exe&lt;/strong&gt; the
application will be installed as a Windows Service. The default identity that it is
installed under is ‘NETWORK SERVICE’. In restricted networks with constrained IPSec
policies (such as the Microsoft Corporate Network), you may have to use a user account
instead. You may also have to use some special Firewall-gateway software such as the
ISA Firewall client to allow for outbound access to ports 828 and 818. 
&lt;/p&gt;
&lt;p&gt;
The actual application code isn’t really all that complicated. The ‘beef’ is in &lt;strong&gt;ReverseWebProxy.cs&lt;/strong&gt;.
What might be surprising here is that this class doesn’t use the WCF Service Model,
but is using naked WCF channels for the upstream traffic to .NET Services and it’s
using HttpWebRequest for the downstream traffic to the local Web Server. The reason
for using channels is that the app is never doing any processing on the messages,
so the channel model is the most straightforward and efficient way. The reason for
using HttpWebRequest is that you can’t suppress auto-redirects on a WCF HTTP client.
Since the stack needs to be completely transparent to redirects so that it’s the browser
client up on top that gets redirected instead of someone on the way, I simply couldn’t
use a WCF channel downstream. Seems to be one of these edge cases that the WCF team
downstairs didn’t think anyone would ever need.
&lt;/p&gt;
&lt;p&gt;
Let me know whether and how this works for you. Share the code, improve it, re-blog,
let me know. @clemensv on Twitter, same name @microsoft.com for email.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=83edb04a-5696-401c-a919-8c1f379d130c" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,83edb04a-5696-401c-a919-8c1f379d130c.aspx</comments>
      <category>.NET Services</category>
      <category>Architecture</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=679ca50b-c907-4831-81c4-369ef7b85839</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,679ca50b-c907-4831-81c4-369ef7b85839.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,679ca50b-c907-4831-81c4-369ef7b85839.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=679ca50b-c907-4831-81c4-369ef7b85839</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:f13e6b20-a745-4e1c-be87-d241bbf94d4b" class="wlWriterEditableSmartContent">
          <p>
XML-RPC for WCF <a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/XMLRPCwithWCFUpdated_8EB8/XmlRpcForWCF.zip" target="_blank">Download
here</a></p>
        </div>
        <p>
        </p>
        <p>
I had updated my WCF XML-RPC stack for PDC’08 but never got around to post it (either
too busy or too lazy when not busy). The updated source code is attached to this post. 
</p>
        <p>
Contrary to the code that I’ve posted a while back, the new XML-RPC implementation
is no longer a binding with a special encoder, but is implemented entirely as a set
of behaviors and extensions for the WCF Service Model. The behavior will work with
WCF 3.5 as it ships in the framework and also with the .NET Service Bus March 2009
CTP.
</p>
        <p>
The resulting Service Model programming experience is completely "normal". That means
you can also expose the XML-RPC contracts as SOAP endpoints with all the advanced
WCF bindings and features if you like. The behaviors support client and service side.
I stripped the config support from this version – I’ll add that back once I get around
to it. Here's a snippet from the MetaWeblog contract:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: [ServiceContract(Namespace = http:<span style="COLOR: #008000">//www.xmlrpc.com/metaWeblogApi)]</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">interface</span> IMetaWeblog
: IBlogger </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:    [OperationContract(Action="<span style="COLOR: #8b0000">metaWeblog.editPost</span>")] </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:    <span style="COLOR: #0000ff">bool</span> metaweblog_editPost(<span style="COLOR: #0000ff">string</span> postid, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:                              <span style="COLOR: #0000ff">string</span> username, </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:                              <span style="COLOR: #0000ff">string</span> password, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:                              Post post,
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:                              <span style="COLOR: #0000ff">bool</span> publish); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:    [OperationContract(Action="<span style="COLOR: #8b0000">metaWeblog.getCategories</span>")] </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:    CategoryInfo[] metaweblog_getCategories( <span style="COLOR: #0000ff">string</span> blogid, </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:                                             <span style="COLOR: #0000ff">string</span> username, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:                                             <span style="COLOR: #0000ff">string</span> password); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:     ...
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17: }</pre>
        </pre>
        <p>
Setting up the endpoint is very easy. Pick the WebHttpBinding (or the WebHttpRelayBinding
for .NET Service Bus), create an endpoint, add the XmlRpcEndpointBehavior to the endpoint
and you’re good to go.
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: Uri baseAddress = <span style="COLOR: #0000ff">new</span> UriBuilder(Uri.UriSchemeHttp,
Environment.MachineName, -1, "<span style="COLOR: #8b0000">/blogdemo/</span>").Uri; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: ServiceHost serviceHost = <span style="COLOR: #0000ff">new</span> ServiceHost(<span style="COLOR: #0000ff">typeof</span>(BloggerAPI)); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: var epXmlRpc = serviceHost.AddServiceEndpoint(
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:                   <span style="COLOR: #0000ff">typeof</span>(IBloggerAPI), </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:                   <span style="COLOR: #0000ff">new</span> WebHttpBinding(WebHttpSecurityMode.None), </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:                   <span style="COLOR: #0000ff">new</span> Uri(baseAddress,
"<span style="COLOR: #8b0000">./blogger</span>")); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: epXmlRpc.Behaviors.Add(<span style="COLOR: #0000ff">new</span> XmlRpcEndpointBehavior());</pre>
        </pre>
        <p>
The client is just as simple:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: Uri blogAddress = <span style="COLOR: #0000ff">new</span> UriBuilder(Uri.UriSchemeHttp,
Environment.MachineName, -1, "<span style="COLOR: #8b0000">/blogdemo/blogger</span>").Uri; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:             
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: ChannelFactory&lt;IBloggerAPI&gt; bloggerAPIFactory = 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:      <span style="COLOR: #0000ff">new</span> ChannelFactory&lt;IBloggerAPI&gt;( </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:              <span style="COLOR: #0000ff">new</span> WebHttpBinding(WebHttpSecurityMode.None), </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:              <span style="COLOR: #0000ff">new</span> EndpointAddress(blogAddress)); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: bloggerAPIFactory.Endpoint.Behaviors.Add(<span style="COLOR: #0000ff">new</span> XmlRpcEndpointBehavior()); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9: IBloggerAPI bloggerAPI = bloggerAPIFactory.CreateChannel();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10: </pre>
        </pre>
        <p>
For your convenience I've included complete Blogger, MetaWeblog, and MovableType API
contracts along with the respective data types in the test applications. The test
app is a small in-memory blog that you can use with the blogging function of Word
2007 or Windows Live Writer or some other blogging client for testing. 
</p>
        <p>
Of the other interesting XML-RPC APIs, the <a href="http://www.hixie.ch/specs/pingback/pingback">Pingback
API</a> has the following contract:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1:  [ServiceContract(Namespace="<span style="COLOR: #8b0000">http://www.hixie.ch/specs/pingback/pingback</span>")] </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:  <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">interface</span> IPingback </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:  {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:      [OperationContract(Action="<span style="COLOR: #8b0000">pingback.ping</span>")] </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:      <span style="COLOR: #0000ff">string</span> ping(<span style="COLOR: #0000ff">string</span> sourceUri, <span style="COLOR: #0000ff">string</span> targetUri); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:  }</pre>
        </pre>
        <p>
and the <a href="http://www.xmlrpc.com/weblogsCom">WeblogUpdates API</a> looks like
this:
</p>
        <span style="LINE-HEIGHT: 115%; FONT-FAMILY: consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">
          <pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1:     [DataContract]</pre>
            <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">struct</span> WeblogUpdatesReply </pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:     {
</pre>
            <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:         [DataMember]
</pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:         <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">bool</span> flerror; </pre>
            <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:         [DataMember]
</pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:         <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">string</span> message; </pre>
            <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     }
</pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9: 
</pre>
            <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     [ServiceContract]
</pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">interface</span> IWeblogUpdates </pre>
            <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:     {
</pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:         [OperationContract(Action = "<span style="COLOR: #8b0000">weblogUpdates.extendedPing</span>")] </pre>
            <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:         WeblogUpdatesReply ExtendedPing(<span style="COLOR: #0000ff">string</span> weblogName, <span style="COLOR: #0000ff">string</span> weblogUrl, <span style="COLOR: #0000ff">string</span> checkUrl, <span style="COLOR: #0000ff">string</span> rssUrl); </pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:         [OperationContract(Action="<span style="COLOR: #8b0000">weblogUpdates.ping</span>")] </pre>
            <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:         WeblogUpdatesReply Ping(<span style="COLOR: #0000ff">string</span> weblogName, <span style="COLOR: #0000ff">string</span> weblogUrl); </pre>
            <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:     }</pre>
          </pre>
          <p>
          </p>
        </span>The code is subject to the Microsoft samples license, which means that
you can freely put it into your (blogging) apps as long as you keep the house out
of trouble.
<img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=679ca50b-c907-4831-81c4-369ef7b85839" /></body>
      <title>XML-RPC with WCF (Updated)</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,679ca50b-c907-4831-81c4-369ef7b85839.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/03/XMLRPC+With+WCF+Updated.aspx</link>
      <pubDate>Fri, 03 Apr 2009 17:09:14 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:f13e6b20-a745-4e1c-be87-d241bbf94d4b class=wlWriterEditableSmartContent&gt;
&lt;p&gt;
XML-RPC for WCF &lt;a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/XMLRPCwithWCFUpdated_8EB8/XmlRpcForWCF.zip" target=_blank&gt;Download
here&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
I had updated my WCF XML-RPC stack for PDC’08 but never got around to post it (either
too busy or too lazy when not busy). The updated source code is attached to this post. 
&lt;/p&gt;
&lt;p&gt;
Contrary to the code that I’ve posted a while back, the new XML-RPC implementation
is no longer a binding with a special encoder, but is implemented entirely as a set
of behaviors and extensions for the WCF Service Model. The behavior will work with
WCF 3.5 as it ships in the framework and also with the .NET Service Bus March 2009
CTP.
&lt;/p&gt;
&lt;p&gt;
The resulting Service Model programming experience is completely "normal". That means
you can also expose the XML-RPC contracts as SOAP endpoints with all the advanced
WCF bindings and features if you like. The behaviors support client and service side.
I stripped the config support from this version – I’ll add that back once I get around
to it. Here's a snippet from the MetaWeblog contract:
&lt;/p&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;  1: [ServiceContract(Namespace = http:&lt;span style="COLOR: #008000"&gt;//www.xmlrpc.com/metaWeblogApi)]&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;interface&lt;/span&gt; IMetaWeblog
: IBlogger &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:    [OperationContract(Action="&lt;span style="COLOR: #8b0000"&gt;metaWeblog.editPost&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;bool&lt;/span&gt; metaweblog_editPost(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; postid, &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: #0000ff"&gt;string&lt;/span&gt; username, &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;string&lt;/span&gt; password, &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:                              Post post,
&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: #0000ff"&gt;bool&lt;/span&gt; publish); &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:    [OperationContract(Action="&lt;span style="COLOR: #8b0000"&gt;metaWeblog.getCategories&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; 12:    CategoryInfo[] metaweblog_getCategories( &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; blogid, &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;string&lt;/span&gt; username, &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: #0000ff"&gt;string&lt;/span&gt; password); &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: 
&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;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
Setting up the endpoint is very easy. Pick the WebHttpBinding (or the WebHttpRelayBinding
for .NET Service Bus), create an endpoint, add the XmlRpcEndpointBehavior to the endpoint
and you’re good to go.
&lt;/p&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;  1: Uri baseAddress = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; UriBuilder(Uri.UriSchemeHttp,
Environment.MachineName, -1, "&lt;span style="COLOR: #8b0000"&gt;/blogdemo/&lt;/span&gt;").Uri; &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 style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: ServiceHost serviceHost = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; ServiceHost(&lt;span style="COLOR: #0000ff"&gt;typeof&lt;/span&gt;(BloggerAPI)); &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: var epXmlRpc = serviceHost.AddServiceEndpoint(
&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;typeof&lt;/span&gt;(IBloggerAPI), &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: #0000ff"&gt;new&lt;/span&gt; WebHttpBinding(WebHttpSecurityMode.None), &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;new&lt;/span&gt; Uri(baseAddress,
"&lt;span style="COLOR: #8b0000"&gt;./blogger&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: epXmlRpc.Behaviors.Add(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlRpcEndpointBehavior());&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The client is just as simple:
&lt;/p&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;  1: Uri blogAddress = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; UriBuilder(Uri.UriSchemeHttp,
Environment.MachineName, -1, "&lt;span style="COLOR: #8b0000"&gt;/blogdemo/blogger&lt;/span&gt;").Uri; &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 style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: ChannelFactory&amp;lt;IBloggerAPI&amp;gt; bloggerAPIFactory = 
&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;new&lt;/span&gt; ChannelFactory&amp;lt;IBloggerAPI&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:              &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; WebHttpBinding(WebHttpSecurityMode.None), &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: #0000ff"&gt;new&lt;/span&gt; EndpointAddress(blogAddress)); &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: bloggerAPIFactory.Endpoint.Behaviors.Add(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlRpcEndpointBehavior()); &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: IBloggerAPI bloggerAPI = bloggerAPIFactory.CreateChannel();
&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&gt;
&lt;p&gt;
For your convenience I've included complete Blogger, MetaWeblog, and MovableType API
contracts along with the respective data types in the test applications. The test
app is a small in-memory blog that you can use with the blogging function of Word
2007 or Windows Live Writer or some other blogging client for testing. 
&lt;/p&gt;
&lt;p&gt;
Of the other interesting XML-RPC APIs, the &lt;a href="http://www.hixie.ch/specs/pingback/pingback"&gt;Pingback
API&lt;/a&gt; has the following contract:
&lt;/p&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;  1:  [ServiceContract(Namespace="&lt;span style="COLOR: #8b0000"&gt;http://www.hixie.ch/specs/pingback/pingback&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;interface&lt;/span&gt; IPingback &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:      [OperationContract(Action="&lt;span style="COLOR: #8b0000"&gt;pingback.ping&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;string&lt;/span&gt; ping(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; sourceUri, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; targetUri); &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;
and the &lt;a href="http://www.xmlrpc.com/weblogsCom"&gt;WeblogUpdates API&lt;/a&gt; looks like
this:
&lt;/p&gt;
&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes"&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;  1:     [DataContract]&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;struct&lt;/span&gt; WeblogUpdatesReply &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:         [DataMember]
&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;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; flerror; &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:         [DataMember]
&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; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; message; &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;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 10:     [ServiceContract]
&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;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;interface&lt;/span&gt; IWeblogUpdates &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:         [OperationContract(Action = "&lt;span style="COLOR: #8b0000"&gt;weblogUpdates.extendedPing&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:         WeblogUpdatesReply ExtendedPing(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; weblogName, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; weblogUrl, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; checkUrl, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; rssUrl); &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:         [OperationContract(Action="&lt;span style="COLOR: #8b0000"&gt;weblogUpdates.ping&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:         WeblogUpdatesReply Ping(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; weblogName, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; weblogUrl); &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;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
&lt;/span&gt;The code is subject to the Microsoft samples license, which means that you
can freely put it into your (blogging) apps as long as you keep the house out of trouble.&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=679ca50b-c907-4831-81c4-369ef7b85839" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,679ca50b-c907-4831-81c4-369ef7b85839.aspx</comments>
      <category>.NET Services</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=6bd1cf32-05e0-455d-84d7-9147c66815be</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,6bd1cf32-05e0-455d-84d7-9147c66815be.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,6bd1cf32-05e0-455d-84d7-9147c66815be.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=6bd1cf32-05e0-455d-84d7-9147c66815be</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Short answer: You can’t. 
</p>
        <p>
There is a range of breaking protocol changes between the December bits and the March
bits. Your app won’t work until you upgrade (uninstall/install) to the March 2009
CTP <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4eff38b3-fca0-4940-a014-461631152e5d&amp;displaylang=en">client
bits</a> and/or <a href="http://www.microsoft.com/downloads/details.aspx?familyid=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;displaylang=en">SDK</a>.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6bd1cf32-05e0-455d-84d7-9147c66815be" />
      </body>
      <title>How do I use the .NET Services "December 2008" CTP SDK with the "March 2009" CTP Services?</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,6bd1cf32-05e0-455d-84d7-9147c66815be.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/03/How+Do+I+Use+The+NET+Services+December+2008+CTP+SDK+With+The+March+2009+CTP+Services.aspx</link>
      <pubDate>Fri, 03 Apr 2009 00:36:18 GMT</pubDate>
      <description>&lt;p&gt;
Short answer: You can’t. 
&lt;/p&gt;
&lt;p&gt;
There is a range of breaking protocol changes between the December bits and the March
bits. Your app won’t work until you upgrade (uninstall/install) to the March 2009
CTP &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4eff38b3-fca0-4940-a014-461631152e5d&amp;amp;displaylang=en"&gt;client
bits&lt;/a&gt; and/or &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;amp;displaylang=en"&gt;SDK&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6bd1cf32-05e0-455d-84d7-9147c66815be" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,6bd1cf32-05e0-455d-84d7-9147c66815be.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=413c6128-a6a6-4894-9cc9-701ffb674ab0</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=413c6128-a6a6-4894-9cc9-701ffb674ab0</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
[If this text looks vaguely familiar you’ve read the HttpQueueSample Readme doc from
the SDK. Good job!]
</p>
        <p>
Here is the Service Bus Queue REST protocol. I apologize if this is a bit dry, but
I want to give you the bare protocol facts first and will follow-up with code samples
later. Look at the HTTP Queue <a href="http://www.microsoft.com/downloads/details.aspx?familyid=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;displaylang=en">SDK
sample</a> if you can’t wait for code ;-)
</p>
        <p>
You can find the HTTP Queue sample in the SDK install path under <em>.\Samples\ServiceBus\ExploringFeatures\Queues\HttpMessages\</em></p>
        <p>
The beauty of REST is that there’s a uniform interface. It’s all just GET, POST, PUT,
DELETE, a set of resources, and a rigorous application of the RFC2616 / HTTP 1.1 rules.
That doesn’t make the description particularly entertaining, but it does yield a pretty
consistent interaction model:
</p>
        <h5>Authorization
</h5>
        <p>
All Queue operations require the client to be appropriately authorized. The client
must therefore acquire an lightweight identity token from the Microsoft .NET Access
Control Service using the .NET Services solution name and the solution password and
include the acquired token with each request. The tokens are added to requests using
the <strong>X-MS-Identity-Token</strong> HTTP header. The value for this header is
a short-lived token which can be used for a period of up to 8 hours and must be acquired
from the .NET Access Control Service. We strongly encourage you to guard the acquired
tokens in the same fashion as you would guard a credential and <strong>you should
not</strong> openly expose them unprotected on the network or web-pages or embedded
in a Flash or Silverlight application. 
</p>
        <p>
        </p>
        <p>
The request for acquiring the token is an HTTPS <strong>GET</strong> on the URI <em><strong>https://accesscontrol.windows.net/issuetoken.aspx?u={solutionName}&amp;p={solutionPassword}</strong></em> whereby
you replace the arguments for solution name and the solution password with your .NET
Services solution credentials. If a token is successfully issued to you the request
returns with a 200 (OK) status code and contains a <em><strong>text/plain</strong></em> entity
body with a short, base64 encoded token hash as a single line of text, which you for
the value of the X-MS-Identity-Token header. 
</p>
        <h5>Creating a Queue
</h5>
        <p>
A Queue is created on the Service Bus in four simple steps. I’ve discussed most of
this in the post on <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">Queue
Policies</a>: 
</p>
        <ol>
          <li>
            <p>
Select a name in the Service Bus naming hierarchy where the Queue should be located,
i.e. <strong>https://</strong><em><strong>mysolution</strong></em><strong>.servicebus.windows.net/myapp/q1</strong></p>
          </li>
          <li>
            <p>
              <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">Create
a Queue policy</a> and define the desired properties of the Queue. 
</p>
          </li>
          <li>
            <p>
Embed the Queue policy into an ATOM 1.0 <em><strong>&lt;atom:entry&gt;</strong></em> as
an extension and <strong>POST</strong> the entry to the designated Queue URI with
the content-type <em><strong>application/atom+xml;type=entry</strong>.</em><em></em>The
request must carry an X-MS-Identity-Token header and the respective identity must
have 'Manage' permission on for scope covering the Queue URI.
</p>
          </li>
          <li>
            <p>
If the queue was successfully created, the POST request returns with a <strong>201</strong> 'created'
status code along with a <strong>Location</strong> header. The response entity body
contains the effective Queue policy as applied to the name by the Service Bus. 
<br /><br />
The location header contains the queue's management URI that you need to retain in
your application state to have access to the queue's metadata and management functions.
If the queue could not be created successfully, the request may yield the following
status codes: 
</p>
            <ul>
              <li>
                <p>
                  <strong>400</strong> - Bad Request. The policy was malformed or invalid.
</p>
              </li>
              <li>
                <p>
                  <strong>403</strong> - Forbidden. The client did not provide a X-MS-Identity-Token
header, the provided token is no longer valid for use, or the provided identity is
not authorized to create a Queue at this location.
</p>
              </li>
              <li>
                <p>
                  <strong>409</strong> - Conflict.  There is already a Queue with an incompatible
policy at the given location or the location is occupied by a Router or a Service
Bus listener.
</p>
              </li>
              <li>
                <p>
                  <strong>415</strong> - Unsupported Media Type. The request did not carry the required
content-type header.
</p>
              </li>
              <li>
                <p>
                  <strong>500</strong> - Internal Server Error. The processing failed to to a condition
internal to the Service Bus service.
</p>
              </li>
            </ul>
          </li>
        </ol>
        <h5>REST Anatomy of a Queue
</h5>
        <p>
Each Queue has five distinct types of resources: <strong>Policy</strong>, <strong>Tail</strong>, <strong>Head</strong>, <strong>Locks</strong>,
and <strong>Control</strong>. The concrete URIs are discoverable using the Service
Registry's Atom Publishing protocol. you should not make any assumptions about the
particular format of the URIs spelled out below since the particular format might
change.
</p>
        <p>
The Atom 1.0 entry shown below is also enclosed in the response entity body of the
create request (POST) explained above. A Queue's representation in the registry feed
as seen when doing a <strong>GET</strong> (discovery-) request on the queue's parent
URI is commonly as follows:
</p>
        <pre>&lt;feed xmlns="http://www.w3.org/2005/Atom"&gt;
  ...
  &lt;entry&gt;
    &lt;id&gt;{id}&lt;/id&gt;
    &lt;title type="text"&gt;MyHttpQueue&lt;/title&gt;
    &lt;updated&gt;{date}&lt;/updated&gt;
    &lt;link rel="alternate" href="https://solution.servicebus.windows.net/myapp/q1" /&gt;
    &lt;link rel="self" href="https://solution.servicebus.windows.net/myapp/q1!(queue)" /&gt;
    &lt;link rel="queuehead" href="https://solution.servicebus.windows.net/myapp/q1!(queue/head)" /&gt;
    &lt;link rel="queuecontrol" href="https://solution.servicebus.windows.net/myapp/q1!(queue/control)" /&gt;
    &lt;QueuePolicy xmlns="http://schemas.microsoft.com/ws/2007/08/connect"&gt;
      &lt;Discoverability&gt;Public&lt;/Discoverability&gt;
      &lt;ExpirationInstant&gt;{expiration}&lt;/ExpirationInstant&gt;
    &lt;/QueuePolicy&gt;
  &lt;/entry&gt;
&lt;/feed&gt;</pre>
        <h5>
        </h5>
        <h5>Managing The Queue
</h5>
        <p>
          <em>&lt;link rel="self" href="https://solution.servicebus.windows.net/myapp/q1!(queue)"
/&gt; 
<br /></em>
          <br />
The "<strong>self</strong>" link in the entry above is the queue's management URI
that allows you to interact with the queue's policy. 
</p>
        <ul>
          <li>
            <p>
To renew a queue and extend its expiration you <strong>PUT</strong> an updated Atom
1.0 entry with the effective policy and an updated <em>ExpirationInstant</em> value
to the "self" URI.  The "self" URI is the same URI as the one returned in the <strong>Location</strong> header
returned by the create POST explained above. The request will yield a <strong>200</strong> status
code if the renewal is successful. It will yield a<strong> 404</strong> if the queue
no longer exists.
</p>
          </li>
          <li>
            <p>
To delete a queue you issue a<strong> DELETE </strong>request on  the queue's
management URI. The Delete request is sent without any entity body and MUST have a
Content-Length header that is set to zero (0). Not setting this header will yield
a <strong>411</strong> status code. The request yields a <strong>204</strong> response
if the queue was deleted successfully.
</p>
          </li>
        </ul>
        <h5>Enqueue
</h5>
        <p>
          <em>&lt;link rel="alternate" href="https://solution.servicebus.windows.net/myapp/q1"
/&gt;</em>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
The "<strong>alternate</strong>" link refers to the tail of the queue. The Queue's <em>tail</em> resource
is where senders submit messages into the Queue. The queue's tail URI is identical
to the URI where the queue was initially created. The queue's tail endpoint accepts
requests with any HTTP Content-Type and any HTTP method except GET, HEAD, and OPTIONS.
</p>
        <p>
The endpoint should be considered a 'delegate' of the message recipient and not the
resource that the respective operations have an immediate effect on. That means that
the HTTP method applied to the Queue tail doesn’t have any particular semantic. If
a message has been successfully accepted into the queue, the request returns a <strong>202</strong> status
code. Otherwise it will return a <strong>500</strong></p>
        <h5>Dequeue and Peek/Lock
</h5>
        <p>
          <em>&lt;link rel="queuehead" href="https://solution.servicebus.windows.net/myapp/q1!(queue/head)"
/&gt;<br /></em>
        </p>
        <p>
The "<strong>queuehead</strong>" link refers to the head of the Queue. The Queue's <em>head</em> resource
is where receivers retrieve messages from the queue. It is modeled as a resource whose
current representation corresponds to the message(s) that reside at the head of the
queue and which is/are next in line to be retrieved by consumers. Permitted operations
on the head are: 
</p>
        <ul>
          <li>
            <strong>DELETE</strong>:  Delete performs a destructive read on the queue whereby
the message(s) at the head of the queue are permanently deleted and returned as the
entity body of the response to the request. The content type and formatting of the
response depends on a set of query parameters that are discussed below. The DELETE
request's response status code is <strong>200</strong> if at least one message could
be retrieved and deleted from the queue and the message content is enclosed in the
response's entity body. The response status code is <strong>204<em></em></strong>if
no message could be retrieved/deleted. 
</li>
          <li>
            <strong>POST:</strong> Post creates a lock on the message(s) at the head of the queue
and returns the locked messages. Locked messages are temporarily removed from the
head of the queue for a period of 1 minute during which time the receiver can decide
whether to return the message to the head of the queue or whether to permanently delete
it. The POST request's response status code is <strong>200</strong> if at least one
message could be retrieved and locked on the queue and the message content is enclosed
in the response's entity body. The response status code is <strong>204<em></em></strong>if
no message could be retrieved/locked.</li>
        </ul>
        <h5>Releasing and Deleting Peek/Lock Message Locks 
</h5>
        <p>
Any retrieved, peek/locked message (POST on “queuehead”) contains an HTTP header <strong>X-MS-Message-Lock </strong>whose
value is a URI. The following operations can be performed on this URI:
</p>
        <ul>
          <li>
            <strong>DELETE: </strong>The message has been accepted/processed by the receiver and
the lock shall be deleted. The deletion of the lock discards the message permanently
from the queue. The Delete request is sent without any entity body and MUST have a
Content-Length header that is set to zero (0). Not setting this header will yield
a <strong>411</strong> status code. The request yields a <strong>204</strong> response
if the lock was deleted successfully. 
</li>
          <li>
            <strong>PUT:</strong>  The message has been not been accepted/processed by the
receiver and the message shall be put back at the head of the queue. This operation
transitions the lock from the locked state into the unlocked state which releases
the message back into the queue. The lock itself is discarded afterwards. The Put
request is sent without any entity body and MUST have a Content-Length header that
is set to zero (0). Not setting this header will yield a <strong>411</strong> status
code. The request yields a <strong>204</strong> response if the lock was released
successfully.</li>
        </ul>
        <h5>Options for Dequeue and Peek/Lock
</h5>
        <p>
The <strong>DELETE</strong> and <strong>POST</strong> operation have a set of options
that are expressed as query parameters appended to the queue's head URI. The options
are the same for both operations:
</p>
        <ul>
          <li>
            <p>
              <strong>timeout=</strong>
              <em>
                <strong>value</strong> - </em>The value is a numerical
value (expressed in seconds) that indicates how long the client is willing to wait
for the polling request to complete. The value should not exceed 60 seconds and a
value of 30 seconds is a safer choice with intermediate proxies in place. If the timeout
expires and no message is available, the request completes with a<strong> 204 </strong>response
code. <strong></strong>The default value is zero (0), which means that the request
returns immediately.<br /></p>
          </li>
          <li>
            <p>
              <strong>maxmessages=<em>value</em></strong>
              <em> - </em>Indicates how many messages
the client is willing to accept in a single response. The default is 1. The service
will return at most 10 messages at a time and a value greater than zero <em>requires</em> encoding=multipart
(see below)<br /></p>
          </li>
          <li>
            <p>
              <strong>encoding=<em>value</em></strong>
              <em> - </em>There are three supported encoding
modes for the REST retrieval model 
</p>
            <ul>
              <li>
                <p>
                  <strong>asreply</strong> - The request stored in the Queue is mapped onto the response
to the DELETE/POST request returning the message from the queue. This option requires
maxmessages=1 or omission of the maxmessages option.
</p>
              </li>
              <li>
                <p>
                  <strong>single</strong> - The request stored in the queue is returned as a complete
HTTP request frame on the response to the DELETE/POST request using Content-Type <strong><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.1">application/http</a></strong>.
This option requires maxmessages=1 or omission of the maxmessages option.
</p>
              </li>
              <li>
                <p>
                  <strong>multipart</strong> - The request(s) stored in the queue are returned as a
complete HTTP request frames on the response to the DELETE/POST request using Content-Type <strong><a href="http://www.ietf.org/rfc/rfc2046.txt">multipart/mixed</a></strong> with
MIME parts of Content-Type <strong><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.1">application/http</a></strong>. 
</p>
              </li>
            </ul>
          </li>
        </ul>
        <h5>Queue Content Control
</h5>
        <p>
          <em>&lt;link rel="queuecontrol" href="https://solution.servicebus.windows.net/myapp/q1!(queue/control)"
/&gt;</em>
        </p>
        <p>
The "<strong>queuecontrol</strong>" link refers to the <em>control</em> resource provides
information about the status of the queue and allows for purging all of the queue's
contents. The control resource is present in the current CTP, but you cannot perform
any operations on it. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=413c6128-a6a6-4894-9cc9-701ffb674ab0" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers And Queues - Part 3: The REST Queue Protocol</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/02/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+3+The+REST+Queue+Protocol.aspx</link>
      <pubDate>Thu, 02 Apr 2009 22:08:13 GMT</pubDate>
      <description>&lt;p&gt;
[If this text looks vaguely familiar you’ve read the HttpQueueSample Readme doc from
the SDK. Good job!]
&lt;/p&gt;
&lt;p&gt;
Here is the Service Bus Queue REST protocol. I apologize if this is a bit dry, but
I want to give you the bare protocol facts first and will follow-up with code samples
later. Look at the HTTP Queue &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;amp;displaylang=en"&gt;SDK
sample&lt;/a&gt; if you can’t wait for code ;-)
&lt;/p&gt;
&lt;p&gt;
You can find the HTTP Queue sample in the SDK install path under &lt;em&gt;.\Samples\ServiceBus\ExploringFeatures\Queues\HttpMessages\&lt;/em&gt; 
&lt;/p&gt;
&lt;p&gt;
The beauty of REST is that there’s a uniform interface. It’s all just GET, POST, PUT,
DELETE, a set of resources, and a rigorous application of the RFC2616 / HTTP 1.1 rules.
That doesn’t make the description particularly entertaining, but it does yield a pretty
consistent interaction model:
&lt;/p&gt;
&lt;h5&gt;Authorization
&lt;/h5&gt;
&lt;p&gt;
All Queue operations require the client to be appropriately authorized. The client
must therefore acquire an lightweight identity token from the Microsoft .NET Access
Control Service using the .NET Services solution name and the solution password and
include the acquired token with each request. The tokens are added to requests using
the &lt;strong&gt;X-MS-Identity-Token&lt;/strong&gt; HTTP header. The value for this header is
a short-lived token which can be used for a period of up to 8 hours and must be acquired
from the .NET Access Control Service. We strongly encourage you to guard the acquired
tokens in the same fashion as you would guard a credential and &lt;strong&gt;you should
not&lt;/strong&gt; openly expose them unprotected on the network or web-pages or embedded
in a Flash or Silverlight application. 
&lt;p&gt;
&lt;p&gt;
The request for acquiring the token is an HTTPS &lt;strong&gt;GET&lt;/strong&gt; on the URI &lt;em&gt;&lt;strong&gt;https://accesscontrol.windows.net/issuetoken.aspx?u={solutionName}&amp;amp;p={solutionPassword}&lt;/strong&gt;&lt;/em&gt; whereby
you replace the arguments for solution name and the solution password with your .NET
Services solution credentials. If a token is successfully issued to you the request
returns with a 200 (OK) status code and contains a &lt;em&gt;&lt;strong&gt;text/plain&lt;/strong&gt;&lt;/em&gt; entity
body with a short, base64 encoded token hash as a single line of text, which you for
the value of the X-MS-Identity-Token header. 
&lt;h5&gt;Creating a Queue
&lt;/h5&gt;
&lt;p&gt;
A Queue is created on the Service Bus in four simple steps. I’ve discussed most of
this in the post on &lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;Queue
Policies&lt;/a&gt;: 
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;
Select a name in the Service Bus naming hierarchy where the Queue should be located,
i.e. &lt;strong&gt;https://&lt;/strong&gt;&lt;em&gt;&lt;strong&gt;mysolution&lt;/strong&gt;&lt;/em&gt;&lt;strong&gt;.servicebus.windows.net/myapp/q1&lt;/strong&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;Create
a Queue policy&lt;/a&gt; and define the desired properties of the Queue. 
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Embed the Queue policy into an ATOM 1.0 &lt;em&gt;&lt;strong&gt;&amp;lt;atom:entry&amp;gt;&lt;/strong&gt;&lt;/em&gt; as
an extension and &lt;strong&gt;POST&lt;/strong&gt; the entry to the designated Queue URI with
the content-type &lt;em&gt;&lt;strong&gt;application/atom+xml;type=entry&lt;/strong&gt;.&lt;/em&gt; &lt;em&gt;&lt;/em&gt;The
request must carry an X-MS-Identity-Token header and the respective identity must
have 'Manage' permission on for scope covering the Queue URI.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
If the queue was successfully created, the POST request returns with a &lt;strong&gt;201&lt;/strong&gt; 'created'
status code along with a &lt;strong&gt;Location&lt;/strong&gt; header. The response entity body
contains the effective Queue policy as applied to the name by the Service Bus. 
&lt;br&gt;
&lt;br&gt;
The location header contains the queue's management URI that you need to retain in
your application state to have access to the queue's metadata and management functions.
If the queue could not be created successfully, the request may yield the following
status codes: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;400&lt;/strong&gt; - Bad Request. The policy was malformed or invalid.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;403&lt;/strong&gt; - Forbidden. The client did not provide a X-MS-Identity-Token
header, the provided token is no longer valid for use, or the provided identity is
not authorized to create a Queue at this location.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;409&lt;/strong&gt; - Conflict.&amp;nbsp; There is already a Queue with an incompatible
policy at the given location or the location is occupied by a Router or a Service
Bus listener.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;415&lt;/strong&gt; - Unsupported Media Type. The request did not carry the required
content-type header.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;500&lt;/strong&gt; - Internal Server Error. The processing failed to to a condition
internal to the Service Bus service.
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h5&gt;REST Anatomy of a Queue
&lt;/h5&gt;
&lt;p&gt;
Each Queue has five distinct types of resources: &lt;strong&gt;Policy&lt;/strong&gt;, &lt;strong&gt;Tail&lt;/strong&gt;, &lt;strong&gt;Head&lt;/strong&gt;, &lt;strong&gt;Locks&lt;/strong&gt;,
and &lt;strong&gt;Control&lt;/strong&gt;. The concrete URIs are discoverable using the Service
Registry's Atom Publishing protocol. you should not make any assumptions about the
particular format of the URIs spelled out below since the particular format might
change.
&lt;/p&gt;
&lt;p&gt;
The Atom 1.0 entry shown below is also enclosed in the response entity body of the
create request (POST) explained above. A Queue's representation in the registry feed
as seen when doing a &lt;strong&gt;GET&lt;/strong&gt; (discovery-) request on the queue's parent
URI is commonly as follows:
&lt;/p&gt;
&lt;pre&gt;&amp;lt;feed xmlns="http://www.w3.org/2005/Atom"&amp;gt;
  ...
  &amp;lt;entry&amp;gt;
    &amp;lt;id&amp;gt;{id}&amp;lt;/id&amp;gt;
    &amp;lt;title type="text"&amp;gt;MyHttpQueue&amp;lt;/title&amp;gt;
    &amp;lt;updated&amp;gt;{date}&amp;lt;/updated&amp;gt;
    &amp;lt;link rel="alternate" href="https://solution.servicebus.windows.net/myapp/q1" /&amp;gt;
    &amp;lt;link rel="self" href="https://solution.servicebus.windows.net/myapp/q1!(queue)" /&amp;gt;
    &amp;lt;link rel="queuehead" href="https://solution.servicebus.windows.net/myapp/q1!(queue/head)" /&amp;gt;
    &amp;lt;link rel="queuecontrol" href="https://solution.servicebus.windows.net/myapp/q1!(queue/control)" /&amp;gt;
    &amp;lt;QueuePolicy xmlns="http://schemas.microsoft.com/ws/2007/08/connect"&amp;gt;
      &amp;lt;Discoverability&amp;gt;Public&amp;lt;/Discoverability&amp;gt;
      &amp;lt;ExpirationInstant&amp;gt;{expiration}&amp;lt;/ExpirationInstant&amp;gt;
    &amp;lt;/QueuePolicy&amp;gt;
  &amp;lt;/entry&amp;gt;
&amp;lt;/feed&amp;gt;&lt;/pre&gt;
&lt;h5&gt;
&lt;/h5&gt;
&lt;h5&gt;Managing The Queue
&lt;/h5&gt;
&lt;p&gt;
&lt;em&gt;&amp;lt;link rel="self" href="https://solution.servicebus.windows.net/myapp/q1!(queue)"
/&amp;gt; 
&lt;br&gt;
&lt;/em&gt;
&lt;br&gt;
The "&lt;strong&gt;self&lt;/strong&gt;" link in the entry above is the queue's management URI
that allows you to interact with the queue's policy. 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
To renew a queue and extend its expiration you &lt;strong&gt;PUT&lt;/strong&gt; an updated Atom
1.0 entry with the effective policy and an updated &lt;em&gt;ExpirationInstant&lt;/em&gt; value
to the "self" URI.&amp;nbsp; The "self" URI is the same URI as the one returned in the &lt;strong&gt;Location&lt;/strong&gt; header
returned by the create POST explained above. The request will yield a &lt;strong&gt;200&lt;/strong&gt; status
code if the renewal is successful. It will yield a&lt;strong&gt; 404&lt;/strong&gt; if the queue
no longer exists.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
To delete a queue you issue a&lt;strong&gt; DELETE &lt;/strong&gt;request on&amp;nbsp; the queue's
management URI. The Delete request is sent without any entity body and MUST have a
Content-Length header that is set to zero (0). Not setting this header will yield
a &lt;strong&gt;411&lt;/strong&gt; status code. The request yields a &lt;strong&gt;204&lt;/strong&gt; response
if the queue was deleted successfully.
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Enqueue
&lt;/h5&gt;
&lt;p&gt;
&lt;em&gt;&amp;lt;link rel="alternate" href="https://solution.servicebus.windows.net/myapp/q1"
/&amp;gt;&lt;/em&gt; 
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
The "&lt;strong&gt;alternate&lt;/strong&gt;" link refers to the tail of the queue. The Queue's &lt;em&gt;tail&lt;/em&gt; resource
is where senders submit messages into the Queue. The queue's tail URI is identical
to the URI where the queue was initially created. The queue's tail endpoint accepts
requests with any HTTP Content-Type and any HTTP method except GET, HEAD, and OPTIONS.
&lt;/p&gt;
&lt;p&gt;
The endpoint should be considered a 'delegate' of the message recipient and not the
resource that the respective operations have an immediate effect on. That means that
the HTTP method applied to the Queue tail doesn’t have any particular semantic. If
a message has been successfully accepted into the queue, the request returns a &lt;strong&gt;202&lt;/strong&gt; status
code. Otherwise it will return a &lt;strong&gt;500&lt;/strong&gt; 
&lt;/p&gt;
&lt;h5&gt;Dequeue and Peek/Lock
&lt;/h5&gt;
&lt;p&gt;
&lt;em&gt;&amp;lt;link rel="queuehead" href="https://solution.servicebus.windows.net/myapp/q1!(queue/head)"
/&amp;gt;&lt;br&gt;
&lt;/em&gt; 
&lt;p&gt;
The "&lt;strong&gt;queuehead&lt;/strong&gt;" link refers to the head of the Queue. The Queue's &lt;em&gt;head&lt;/em&gt; resource
is where receivers retrieve messages from the queue. It is modeled as a resource whose
current representation corresponds to the message(s) that reside at the head of the
queue and which is/are next in line to be retrieved by consumers. Permitted operations
on the head are: 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DELETE&lt;/strong&gt;:&amp;nbsp; Delete performs a destructive read on the queue whereby
the message(s) at the head of the queue are permanently deleted and returned as the
entity body of the response to the request. The content type and formatting of the
response depends on a set of query parameters that are discussed below. The DELETE
request's response status code is &lt;strong&gt;200&lt;/strong&gt; if at least one message could
be retrieved and deleted from the queue and the message content is enclosed in the
response's entity body. The response status code is &lt;strong&gt;204&lt;em&gt; &lt;/em&gt;&lt;/strong&gt;if
no message could be retrieved/deleted. 
&lt;li&gt;
&lt;strong&gt;POST:&lt;/strong&gt; Post creates a lock on the message(s) at the head of the queue
and returns the locked messages. Locked messages are temporarily removed from the
head of the queue for a period of 1 minute during which time the receiver can decide
whether to return the message to the head of the queue or whether to permanently delete
it. The POST request's response status code is &lt;strong&gt;200&lt;/strong&gt; if at least one
message could be retrieved and locked on the queue and the message content is enclosed
in the response's entity body. The response status code is &lt;strong&gt;204&lt;em&gt; &lt;/em&gt;&lt;/strong&gt;if
no message could be retrieved/locked.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Releasing and Deleting Peek/Lock Message Locks 
&lt;/h5&gt;
&lt;p&gt;
Any retrieved, peek/locked message (POST on “queuehead”) contains an HTTP header &lt;strong&gt;X-MS-Message-Lock &lt;/strong&gt;whose
value is a URI. The following operations can be performed on this URI:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DELETE: &lt;/strong&gt;The message has been accepted/processed by the receiver and
the lock shall be deleted. The deletion of the lock discards the message permanently
from the queue. The Delete request is sent without any entity body and MUST have a
Content-Length header that is set to zero (0). Not setting this header will yield
a &lt;strong&gt;411&lt;/strong&gt; status code. The request yields a &lt;strong&gt;204&lt;/strong&gt; response
if the lock was deleted successfully. 
&lt;li&gt;
&lt;strong&gt;PUT:&lt;/strong&gt;&amp;nbsp; The message has been not been accepted/processed by the
receiver and the message shall be put back at the head of the queue. This operation
transitions the lock from the locked state into the unlocked state which releases
the message back into the queue. The lock itself is discarded afterwards. The Put
request is sent without any entity body and MUST have a Content-Length header that
is set to zero (0). Not setting this header will yield a &lt;strong&gt;411&lt;/strong&gt; status
code. The request yields a &lt;strong&gt;204&lt;/strong&gt; response if the lock was released
successfully.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Options for Dequeue and Peek/Lock
&lt;/h5&gt;
&lt;p&gt;
The &lt;strong&gt;DELETE&lt;/strong&gt; and &lt;strong&gt;POST&lt;/strong&gt; operation have a set of options
that are expressed as query parameters appended to the queue's head URI. The options
are the same for both operations:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;timeout=&lt;/strong&gt;&lt;em&gt;&lt;strong&gt;value&lt;/strong&gt; - &lt;/em&gt;The value is a numerical
value (expressed in seconds) that indicates how long the client is willing to wait
for the polling request to complete. The value should not exceed 60 seconds and a
value of 30 seconds is a safer choice with intermediate proxies in place. If the timeout
expires and no message is available, the request completes with a&lt;strong&gt; 204 &lt;/strong&gt;response
code. &lt;strong&gt;&lt;/strong&gt;The default value is zero (0), which means that the request
returns immediately.&lt;br&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;maxmessages=&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;&lt;em&gt; - &lt;/em&gt;Indicates how many messages
the client is willing to accept in a single response. The default is 1. The service
will return at most 10 messages at a time and a value greater than zero &lt;em&gt;requires&lt;/em&gt; encoding=multipart
(see below)&lt;br&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;encoding=&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;&lt;em&gt; - &lt;/em&gt;There are three supported encoding
modes for the REST retrieval model 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;asreply&lt;/strong&gt; - The request stored in the Queue is mapped onto the response
to the DELETE/POST request returning the message from the queue. This option requires
maxmessages=1 or omission of the maxmessages option.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;single&lt;/strong&gt; - The request stored in the queue is returned as a complete
HTTP request frame on the response to the DELETE/POST request using Content-Type &lt;strong&gt;&lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.1"&gt;application/http&lt;/a&gt;&lt;/strong&gt;.
This option requires maxmessages=1 or omission of the maxmessages option.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;multipart&lt;/strong&gt; - The request(s) stored in the queue are returned as a
complete HTTP request frames on the response to the DELETE/POST request using Content-Type &lt;strong&gt;&lt;a href="http://www.ietf.org/rfc/rfc2046.txt"&gt;multipart/mixed&lt;/a&gt;&lt;/strong&gt; with
MIME parts of Content-Type &lt;strong&gt;&lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.1"&gt;application/http&lt;/a&gt;&lt;/strong&gt;. 
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Queue Content Control
&lt;/h5&gt;
&lt;p&gt;
&lt;em&gt;&amp;lt;link rel="queuecontrol" href="https://solution.servicebus.windows.net/myapp/q1!(queue/control)"
/&amp;gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
The "&lt;strong&gt;queuecontrol&lt;/strong&gt;" link refers to the &lt;em&gt;control&lt;/em&gt; resource provides
information about the status of the queue and allows for purging all of the queue's
contents. The control resource is present in the current CTP, but you cannot perform
any operations on it. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=413c6128-a6a6-4894-9cc9-701ffb674ab0" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=0f64f592-7239-42fc-aed2-f0993701c5f6</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=0f64f592-7239-42fc-aed2-f0993701c5f6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx">In
the previous post in this series</a> I’ve discussed some of the foundational principles
of the new Queue and Router features of the .NET Services Bus and the role that policies
play in turning names in the namespace into messaging primitives. In this post I’ll
start drilling into the capabilities of the Queue feature and will discuss what’s
in the queue policy. 
</p>
        <p>
The capabilities of the Queue are best explored by looking at the Queue policy. Policies
can be expressed in two ways: You can either you use the .NET Services SDK’s <strong>Microsoft.ServiceBus.QueuePolicy</strong> class
with a .NET application or you can just whip up a bit of XML. The structure and the
serialized representation of that class is exactly equivalent to an XML queue policy
you’d wire up “by hand” and thus I’ll discuss the policy in terms of its XML elements:
</p>
        <p>
The queue policy has the element name “<strong>QueuePolicy</strong>” within the XML
namespace “<em><strong>http://schemas.microsoft.com/ws/2007/08/connect</strong>”. </em>That’s
the namespace we use for most protocols and data structures in the .NET Service Bus
at this development stage and you should expect that we’re migrating to the “final”
V1 namespaces in one of the next CTPs.  If you use the .NET class you’ll just
have to recompile to snap to new namespaces once they come around.
</p>
        <p>
Below is a list of the policy’s elements and the permitted values. All elements are
optional and can appear at most once. The default value applies when an element is
omitted. It’s perfectly ok to send an empty <em>QueuePolicy</em> and accept the default
values to keep things simple. I’d recommend to always set the <em>ExpirationInstant</em> value,
however. 
</p>
        <p>
One required forward reference: Don’t get confused or distracted trying to figure
out from here what it means “to provide an authorization token”. The docs explain
this and I’ll also address this in the next blog post when I dive into the protocol. 
</p>
        <ul>
          <li>
            <strong>Authorization</strong> – The authorization setting indicates whether sender
and/or consumers must provide a security token when interacting with the queue. You
can explicitly permit the .NET Service Bus to allow anonymous consumers and/or anonymous
senders on a Queue. If a token is required, a sender must present a token with “Send”
permission that is issued by the .NET Access Control service and the consumer must
present a token with “Listen” permission that is issued by the .NET Access Control
service. The respective rules are set up in the .NET Access Control service on your
project’s “Service Bus” scope. Mind that all anonymous traffic is attributed to the
“manager” of a Queue, i.e. to whoever sets the policy; all traffic is metered and
accounted for. The permitted values for this element are: 
<ul><li><strong>Required</strong> – (default) Senders and Consumers must provide an authorization
token to send/retrieve messages. 
</li><li><strong>RequiredToSend</strong> – Senders must provide an authorization token with
a “Send” claim to send messages, consumers don’t. 
</li><li><strong>RequiredToReceive</strong> – Consumers must provide an authorization token
with a “Listen” claim to receiver messages, senders don’t. 
</li><li><strong>NotRequired</strong> – Neither senders nor consumers must provide a token,
i.e. the queue is set up for anonymous traffic.<br /></li></ul></li>
          <li>
            <strong>Discoverability</strong> – The discoverability setting defines under which
conditions the Queue and its policy are visible in the Service Registry Atom feed
and any forthcoming discoverability mechanisms. When you are browsing the Service
Registry feed from within a browser, the only setting that will make the Queue visible
is <em>Public</em> since the browser isn’t able to attach an authorization token without
some scripting assistance.  
<ul><li><strong>Managers</strong> - (default) The Queue and its policy are only discoverable
if you provide an authorization token with the request and the token carries a “Manage”
claim. 
</li><li><strong>ManagersListeners</strong> – The Queue and its policy are only discoverable
if you provide and authorization token with the request and the token carries a “Manage”
and/or “Listen” claim. 
</li><li><strong>ManagersListenersSenders</strong> – The Queue and its policy are only discoverable
if you provide and authorization token with the request and the token carries a “Manage”
and/or “Listen” and/or “Send” claim. 
</li><li><strong>Public</strong> – The Queue and its policy are discoverable without any authorization
requirement, i.e. the general public.<br /></li></ul></li>
          <li>
            <strong>ExpirationInstant</strong> – This is an XML dateTime value indicating the
TTL (time-to-live) for the Queue. You can make Queues long-lived or short-lived. A
Queue’s lifetime may be extended by changing this policy value and reapplying the
policy. Once a Queue expires it is removed from the system along with all the messages
that reside in it. The system may limit the Queue lifetime in the effective policy
that you get back from the create/update request, but we’ll typically allow at least
24 hours without renewal. This value has a default of 24 hours, a maximum of 21 days
and a minimum of 30 seconds. The value must represent a future dateTime and must be
expressed in UTC. 
<br /></li>
          <li>
            <strong>MaxMessageSize</strong> – This is a numeric value defining the maximum size
of any individual message that can be accepted into the Queue. The maximum message
size is expressed in bytes and includes all infrastructure-imposed and encoding-related
overhead. The actual overhead varies significantly based on whether messages are sent
as SOAP 1.1, SOAP 1.2, or plain HTTP frames using text or binary encoding and whether
a security token is required. A very defensive assumption is to reserve 10-12KB for
protocol overhead in complex cases with WS* Security; the minimal allocation for protocol
overhead should be around 4KB. The <strong>default</strong> and <strong>maximum</strong> values
for the maximum message size is <strong>60KB</strong> (60*1024 bytes). The minimum
value is <strong>8KB</strong>. We suggest that the <strong>payload size</strong> for
an individual message does <strong>not exceed</strong><strong>48KB</strong>, even
though you can try to push it a bit. The expectation is that these values will trend
up but I don’t see them more than doubling due to throughput, timeliness and scale
considerations. If your data is larger you should consider how you can chunk it up. 
<br /></li>
          <li>
            <strong>TransportProtection</strong> – The transport protection setting defines whether
senders and consumers <strong>must</strong> use HTTPS to interact with the Queue.
This is the default setting. You would modify this to accommodate clients – typically
on devices - that don’t do HTTPS all that well. Permitted values:  
<ul><li><strong>AllPaths</strong> - (default) Any interaction with the queue requires HTTPS. 
</li><li><strong>None</strong> – Any interaction may be performed using either HTTP or HTTPS.<br /></li></ul></li>
          <li>
            <strong>EnqueueTimeout</strong> – The enqueue timeout is an XML duration value that
specifies how long an enqueue operation will hang if the queue is at capacity (full).
The default value is 10 seconds, the minimum is 0 seconds, and the maximum is 60 seconds.
If the timeout expires and the message could not be added to the queue during that
time, the queue will act according to the <strong>Overflow</strong> policy setting. 
<br /></li>
          <li>
            <strong>MaxConcurrentReaders</strong> - <font color="#ff8000">[this setting not supported/enforced
in the March 2009 CTP]</font> The <em>maximum concurrent readers</em> value defines
how many concurrent readers are permitted on the queue. If this numeric value is smaller
than the default value of 2^31 (max int), the queue protocol will switch into ‘session
mode’ that grants a limited number of read-locks on the queue. The minimum value is
1. 
<br /></li>
          <li>
            <strong>MaxDequeueRetries</strong> - <font color="#ff8000">[this setting not supported/enforced
in the March 2009 CTP]</font> The <em>maximum dequeue retries</em> value defines how
often a message may be peek/locked and put back into the queue until it is considered
poisonous, i.e. after how many retries it should be expected the the consumer will
not be able to ever consume the message successfully, because it is malformed or the
consumer experiences an error condition that requires some form of manual intervention
(including a bug fix). If the message is found to be poisonous it will be sent once
and without any retries to the endpoint specified in the policy’s <strong>PoisonMessageDrop</strong> value. 
<br /></li>
          <li>
            <strong>MaxMessageAge</strong> – The <em>maximum message age</em> is an XML duration
value indicating after what time any enqueued message is considered ‘stale” and will
be automatically dropped and removed from the queue. The default value is 10 minutes
(600 seconds), the minimum value is 0 seconds (which effectively means that all incoming
messages get dropped), the maximum value is 7 days. 
<br /></li>
          <li>
            <strong>MaxQueueCapacity</strong> – This numeric value indicates the maximum size
of the Queue in bytes. This is a system-calculated value that cannot be set on the
.NET class and should not be set by clients creating policies from scratch. The default
and <strong>maximum capacity</strong> of any queue is currently capped at <strong>2MB</strong>.
This is a limitation specific to the March 2009 CTP , it’s been painful to impose
this constraint, and it’s absolutely expected that this limit will be expanded significantly.
2MB still allow for a several hundred notification messages of a 2-4KB. If you need
to store more data you can absolutely create several queues and partition data across
them either explicitly or using Routers with a load-balancing message distribution
policy (more on that in a subsequent post). 
<br /></li>
          <li>
            <strong>MaxQueueLength</strong> – This numeric value indicates the maximum queue length.
The maximum and default value is 2^31, the minimum value is 1. <font color="#ff8000">We’re
not enforcing the exact queue length in the March 2009 CTP</font>, but your code should
assume that we do. The queue length value is the basis for the calculation of the <strong>MaxQueueCapacity</strong>,
with MaxQueueCapacity = min(MaxQueueLength * MaxMessageSize, 2MB) enforcing the hard
2MB limit that is currently in effect. You don’t need to touch this value unless you’d
really want a Queue that’s even more size-constrained. 
<br /></li>
          <li>
            <strong>Overflow</strong> – The overflow policy setting becomes relevant when the
queue is at capacity and the <strong>EnqueueTimeout</strong> has expired. It tells
the Queue what to do with the message that just came in and that can’t be put into
the queue because it’s full. Permitted values:  
<ul><li><strong>RejectIncomingMessage</strong> - (default) The message will be rejected and
an error status code or SOAP fault will be sent to the sender. 
</li><li><strong>DiscardIncomingMessage</strong> – The sender will get an indication that the
message has been accepted, but the message will be dropped on the floor. 
</li><li><strong>DiscardExistingMessage</strong> – The Queue will remove and discard messages
from the head of the Queue until the new, incoming message fits in the Queue.<br /></li></ul></li>
          <li>
            <strong>PoisonMessageDrop</strong> – <font color="#ff8000">[this setting not supported
in the March 2009 CTP]</font> This value is a WS-Addressing 1.0 EndpointReference
referring to an endpoint that any poison messages will be sent to once the <strong>MaxDequeueRetries</strong> limit
has been exceeded. The EndpointReference may point to any SOAP or plain HTTP endpoint
that can accept ‘any’ message. 
</li>
        </ul>
        <p>
Phew! Lots of options. The good thing is that most apps should be ok with the defaults. 
</p>
        <p>
I know that the 2MB capacity limit is somewhat disappointing and I’m certainly not
happy with it. There’s a particular behavior (with bug number) that may occur under
very rare circumstances in the underlying replication system, which caused us to play
it very safe instead of risking data loss. I don’t think the limit is a showstopper
for apps that send notifications and events around – it is a showstopper for apps
that want to exchange larger payloads and we’re working to relax that limit and make
Queues much, much larger as soon as we can. You can obviously always spool larger
data into SDS or one of the Azure storage systems and then send a reference to that
data as a message, but it’d be strange for a messaging system to make that a required
pattern for data of all sizes. If we’re talking hundreds of megabytes it makes sense,
though.
</p>
        <p>
With the due apology out of the way, let’s look at how a policy may be applied to
a namespace name – or in other words, how a queue is created in the simplest case
(this must be done via HTTPS). The model here is that the client <em>proposes</em> a
policy and Service Bus is at liberty to adjust the policy. 
</p>
        <p>
If you are intimately familiar with Atom, you’ll notice that the &lt;QueuePolicy&gt;
is an extension and isn’t carried as &lt;content&gt;. That’s by intent. &lt;content&gt;
is for people, extensions are for apps. We’ll start using &lt;content&gt; in a later
milestone, so consider that being <em>reserved</em>.
</p>
        <p>
          <font face="Courier New">
            <strong>HTTP/1.1 POST /myapp/q1<br />
Host: clemensv.servicebus.windows.net<br />
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==<br />
Content-Type: application/atom+xml;type=entry;charset=utf-8<br />
Content-Length: nnn<br /><br />
&lt;entry xmlns=”<em>http://www.w3.org/2005/Atom</em>”&gt;<br />
   &lt;QueuePolicy xmlns=”</strong>
            <strong>
              <em>http://schemas.microsoft.com/ws/2007/08/connect”&gt;<br />
      &lt;ExpirationInstant&gt;2009-04-03T12:00:00&lt;/ExpirationInstant&gt;<br />
   &lt;/QueuePolicy&gt; </em>
              <br />
&lt;/entry&gt;</strong>
          </font>
        </p>
        <p>
If the queue can be created, the response is a 200 and you get the policy back along
with any adjustments that the service may make. This is called the “effective” policy,
i.e. that’s what the server is using. You also learn about where you can modify the
policy, since – <a href="http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx">as
I explained before</a> – the endpoint where you POST the policy to is morphing into
the Queue’s tail.
</p>
        <p>
          <font face="Courier New">
            <strong>HTTP/1.1 200 OK<br />
Location: https://project-name.servicebus.windows.net/myapp/q1!(queue)<br />
Content-Type: application/atom+xml;type=entry;charset=utf-8<br />
Content-Length: nnn<br /><br />
&lt;entry xmlns=”<em>http://www.w3.org/2005/Atom</em>”&gt;<br />
   &lt;link rel=”self” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue)”
/&gt;<br />
   &lt;link rel=”alternate” href=”https://project-name.servicebus.windows.net/myapp/q1”
/&gt; 
<br />
   &lt;link rel=”queuehead” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue/head)”
/&gt; 
<br />
   &lt;QueuePolicy xmlns=”</strong>
          </font>
          <font face="Courier New">
            <strong>
              <em>http://schemas.microsoft.com/ws/2007/08/connect”
&gt;<br /></em>         &lt;ExpirationInstant&gt;2009-04-03T12:00:00&lt;/ExpirationInstant&gt;<br />
         &lt;MaxQueueCapacity&gt;2097152&lt;/MaxQueueCapacity&gt;<br />
   &lt;/QueuePolicy&gt;<br />
&lt;/entry&gt;</strong>
          </font>
        </p>
        <p>
If you want to renew the Queue (extend the expiration), take the effective policy,
adjust ExpirationInstant and do a PUT to the “self” location. 
</p>
        <p>
          <strong>
            <font face="Courier New">HTTP/1.1 PUT /myapp/q1<font color="#ff0000">!(queue)</font><br />
Host: project-name.servicebus.windows.net<br />
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==<br />
Content-Type: application/atom+xml;type=entry;charset=utf-8<br />
Content-Length: nnn<br /><br /></font>
          </strong>
          <strong>
            <font face="Courier New">&lt;entry xmlns=”<em>http://www.w3.org/2005/Atom</em>”&gt;<br />
   &lt;link rel=”self” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue)”
/&gt;<br />
   &lt;link rel=”alternate” href=”https://project-name.servicebus.windows.net/myapp/q1”
/&gt; 
<br />
   &lt;link rel=”queuehead” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue/head)”
/&gt; 
<br />
   &lt;QueuePolicy xmlns=”</font>
          </strong>
          <strong>
            <font face="Courier New">
              <em>http://schemas.microsoft.com/ws/2007/08/connect”
&gt;<br /></em>         &lt;ExpirationInstant&gt;<font color="#ff0000">2009-04-04T12:00:00</font>&lt;/ExpirationInstant&gt;<br />
         &lt;MaxQueueCapacity&gt;2097152&lt;/MaxQueueCapacity&gt;<br />
   &lt;/QueuePolicy&gt;<br />
&lt;/entry&gt;</font>
          </strong>
        </p>
        <p>
[<strong><font color="#008080">Bug note:</font></strong> The PUT will return the new
effective policy just like the POST response shown above, but the returned Atom &lt;links&gt;
aren’t correctly formed. Keep the ones returned from the POST]
</p>
        <p>
If you want to delete the queue, just nuke the policy:
</p>
        <p>
          <strong>
            <font face="Courier New">HTTP/1.1 DELETE /myapp/q1<font color="#ff0000">!(queue)</font><br />
Host: project-name.servicebus.windows.net<br />
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==<br />
Content-Length: 0</font>
          </strong>
        </p>
        <p>
So that’s the policy story for Queues. In the next posts I’ll discuss the REST Queue
protocol and the SOAP Queue protocol for how you send message to the queue and get
messages out. REST I’ll explain in protocol terms, the SOAP model in .NET programming
model terms. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=0f64f592-7239-42fc-aed2-f0993701c5f6" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers And Queues - Part 2: Queue Policies</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/02/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+2+Queue+Policies.aspx</link>
      <pubDate>Thu, 02 Apr 2009 20:10:25 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx"&gt;In
the previous post in this series&lt;/a&gt; I’ve discussed some of the foundational principles
of the new Queue and Router features of the .NET Services Bus and the role that policies
play in turning names in the namespace into messaging primitives. In this post I’ll
start drilling into the capabilities of the Queue feature and will discuss what’s
in the queue policy. 
&lt;/p&gt;
&lt;p&gt;
The capabilities of the Queue are best explored by looking at the Queue policy. Policies
can be expressed in two ways: You can either you use the .NET Services SDK’s &lt;strong&gt;Microsoft.ServiceBus.QueuePolicy&lt;/strong&gt; class
with a .NET application or you can just whip up a bit of XML. The structure and the
serialized representation of that class is exactly equivalent to an XML queue policy
you’d wire up “by hand” and thus I’ll discuss the policy in terms of its XML elements:
&lt;/p&gt;
&lt;p&gt;
The queue policy has the element name “&lt;strong&gt;QueuePolicy&lt;/strong&gt;” within the XML
namespace “&lt;em&gt;&lt;strong&gt;http://schemas.microsoft.com/ws/2007/08/connect&lt;/strong&gt;”. &lt;/em&gt;That’s
the namespace we use for most protocols and data structures in the .NET Service Bus
at this development stage and you should expect that we’re migrating to the “final”
V1 namespaces in one of the next CTPs.&amp;nbsp; If you use the .NET class you’ll just
have to recompile to snap to new namespaces once they come around.
&lt;/p&gt;
&lt;p&gt;
Below is a list of the policy’s elements and the permitted values. All elements are
optional and can appear at most once. The default value applies when an element is
omitted. It’s perfectly ok to send an empty &lt;em&gt;QueuePolicy&lt;/em&gt; and accept the default
values to keep things simple. I’d recommend to always set the &lt;em&gt;ExpirationInstant&lt;/em&gt; value,
however. 
&lt;/p&gt;
&lt;p&gt;
One required forward reference: Don’t get confused or distracted trying to figure
out from here what it means “to provide an authorization token”. The docs explain
this and I’ll also address this in the next blog post when I dive into the protocol. 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authorization&lt;/strong&gt; – The authorization setting indicates whether sender
and/or consumers must provide a security token when interacting with the queue. You
can explicitly permit the .NET Service Bus to allow anonymous consumers and/or anonymous
senders on a Queue. If a token is required, a sender must present a token with “Send”
permission that is issued by the .NET Access Control service and the consumer must
present a token with “Listen” permission that is issued by the .NET Access Control
service. The respective rules are set up in the .NET Access Control service on your
project’s “Service Bus” scope. Mind that all anonymous traffic is attributed to the
“manager” of a Queue, i.e. to whoever sets the policy; all traffic is metered and
accounted for. The permitted values for this element are: 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Required&lt;/strong&gt; – (default) Senders and Consumers must provide an authorization
token to send/retrieve messages. 
&lt;li&gt;
&lt;strong&gt;RequiredToSend&lt;/strong&gt; – Senders must provide an authorization token with
a “Send” claim to send messages, consumers don’t. 
&lt;li&gt;
&lt;strong&gt;RequiredToReceive&lt;/strong&gt; – Consumers must provide an authorization token
with a “Listen” claim to receiver messages, senders don’t. 
&lt;li&gt;
&lt;strong&gt;NotRequired&lt;/strong&gt; – Neither senders nor consumers must provide a token,
i.e. the queue is set up for anonymous traffic.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
&lt;strong&gt;Discoverability&lt;/strong&gt; – The discoverability setting defines under which
conditions the Queue and its policy are visible in the Service Registry Atom feed
and any forthcoming discoverability mechanisms. When you are browsing the Service
Registry feed from within a browser, the only setting that will make the Queue visible
is &lt;em&gt;Public&lt;/em&gt; since the browser isn’t able to attach an authorization token without
some scripting assistance.&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Managers&lt;/strong&gt; - (default) The Queue and its policy are only discoverable
if you provide an authorization token with the request and the token carries a “Manage”
claim. 
&lt;li&gt;
&lt;strong&gt;ManagersListeners&lt;/strong&gt; – The Queue and its policy are only discoverable
if you provide and authorization token with the request and the token carries a “Manage”
and/or “Listen” claim. 
&lt;li&gt;
&lt;strong&gt;ManagersListenersSenders&lt;/strong&gt; – The Queue and its policy are only discoverable
if you provide and authorization token with the request and the token carries a “Manage”
and/or “Listen” and/or “Send” claim. 
&lt;li&gt;
&lt;strong&gt;Public&lt;/strong&gt; – The Queue and its policy are discoverable without any authorization
requirement, i.e. the general public.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
&lt;strong&gt;ExpirationInstant&lt;/strong&gt; – This is an XML dateTime value indicating the
TTL (time-to-live) for the Queue. You can make Queues long-lived or short-lived. A
Queue’s lifetime may be extended by changing this policy value and reapplying the
policy. Once a Queue expires it is removed from the system along with all the messages
that reside in it. The system may limit the Queue lifetime in the effective policy
that you get back from the create/update request, but we’ll typically allow at least
24 hours without renewal. This value has a default of 24 hours, a maximum of 21 days
and a minimum of 30 seconds. The value must represent a future dateTime and must be
expressed in UTC. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxMessageSize&lt;/strong&gt; – This is a numeric value defining the maximum size
of any individual message that can be accepted into the Queue. The maximum message
size is expressed in bytes and includes all infrastructure-imposed and encoding-related
overhead. The actual overhead varies significantly based on whether messages are sent
as SOAP 1.1, SOAP 1.2, or plain HTTP frames using text or binary encoding and whether
a security token is required. A very defensive assumption is to reserve 10-12KB for
protocol overhead in complex cases with WS* Security; the minimal allocation for protocol
overhead should be around 4KB. The &lt;strong&gt;default&lt;/strong&gt; and &lt;strong&gt;maximum&lt;/strong&gt; values
for the maximum message size is &lt;strong&gt;60KB&lt;/strong&gt; (60*1024 bytes). The minimum
value is &lt;strong&gt;8KB&lt;/strong&gt;. We suggest that the &lt;strong&gt;payload size&lt;/strong&gt; for
an individual message does &lt;strong&gt;not exceed&lt;/strong&gt; &lt;strong&gt;48KB&lt;/strong&gt;, even
though you can try to push it a bit. The expectation is that these values will trend
up but I don’t see them more than doubling due to throughput, timeliness and scale
considerations. If your data is larger you should consider how you can chunk it up. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;TransportProtection&lt;/strong&gt; – The transport protection setting defines whether
senders and consumers &lt;strong&gt;must&lt;/strong&gt; use HTTPS to interact with the Queue.
This is the default setting. You would modify this to accommodate clients – typically
on devices - that don’t do HTTPS all that well. Permitted values:&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AllPaths&lt;/strong&gt; - (default) Any interaction with the queue requires HTTPS. 
&lt;li&gt;
&lt;strong&gt;None&lt;/strong&gt; – Any interaction may be performed using either HTTP or HTTPS.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
&lt;strong&gt;EnqueueTimeout&lt;/strong&gt; – The enqueue timeout is an XML duration value that
specifies how long an enqueue operation will hang if the queue is at capacity (full).
The default value is 10 seconds, the minimum is 0 seconds, and the maximum is 60 seconds.
If the timeout expires and the message could not be added to the queue during that
time, the queue will act according to the &lt;strong&gt;Overflow&lt;/strong&gt; policy setting. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxConcurrentReaders&lt;/strong&gt; - &lt;font color=#ff8000&gt;[this setting not supported/enforced
in the March 2009 CTP]&lt;/font&gt; The &lt;em&gt;maximum concurrent readers&lt;/em&gt; value defines
how many concurrent readers are permitted on the queue. If this numeric value is smaller
than the default value of 2^31 (max int), the queue protocol will switch into ‘session
mode’ that grants a limited number of read-locks on the queue. The minimum value is
1. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxDequeueRetries&lt;/strong&gt; - &lt;font color=#ff8000&gt;[this setting not supported/enforced
in the March 2009 CTP]&lt;/font&gt; The &lt;em&gt;maximum dequeue retries&lt;/em&gt; value defines how
often a message may be peek/locked and put back into the queue until it is considered
poisonous, i.e. after how many retries it should be expected the the consumer will
not be able to ever consume the message successfully, because it is malformed or the
consumer experiences an error condition that requires some form of manual intervention
(including a bug fix). If the message is found to be poisonous it will be sent once
and without any retries to the endpoint specified in the policy’s &lt;strong&gt;PoisonMessageDrop&lt;/strong&gt; value. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxMessageAge&lt;/strong&gt; – The &lt;em&gt;maximum message age&lt;/em&gt; is an XML duration
value indicating after what time any enqueued message is considered ‘stale” and will
be automatically dropped and removed from the queue. The default value is 10 minutes
(600 seconds), the minimum value is 0 seconds (which effectively means that all incoming
messages get dropped), the maximum value is 7 days. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxQueueCapacity&lt;/strong&gt; – This numeric value indicates the maximum size
of the Queue in bytes. This is a system-calculated value that cannot be set on the
.NET class and should not be set by clients creating policies from scratch. The default
and &lt;strong&gt;maximum capacity&lt;/strong&gt; of any queue is currently capped at &lt;strong&gt;2MB&lt;/strong&gt;.
This is a limitation specific to the March 2009 CTP , it’s been painful to impose
this constraint, and it’s absolutely expected that this limit will be expanded significantly.
2MB still allow for a several hundred notification messages of a 2-4KB. If you need
to store more data you can absolutely create several queues and partition data across
them either explicitly or using Routers with a load-balancing message distribution
policy (more on that in a subsequent post). 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxQueueLength&lt;/strong&gt; – This numeric value indicates the maximum queue length.
The maximum and default value is 2^31, the minimum value is 1. &lt;font color=#ff8000&gt;We’re
not enforcing the exact queue length in the March 2009 CTP&lt;/font&gt;, but your code should
assume that we do. The queue length value is the basis for the calculation of the &lt;strong&gt;MaxQueueCapacity&lt;/strong&gt;,
with MaxQueueCapacity = min(MaxQueueLength * MaxMessageSize, 2MB) enforcing the hard
2MB limit that is currently in effect. You don’t need to touch this value unless you’d
really want a Queue that’s even more size-constrained. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;Overflow&lt;/strong&gt; – The overflow policy setting becomes relevant when the
queue is at capacity and the &lt;strong&gt;EnqueueTimeout&lt;/strong&gt; has expired. It tells
the Queue what to do with the message that just came in and that can’t be put into
the queue because it’s full. Permitted values:&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RejectIncomingMessage&lt;/strong&gt; - (default) The message will be rejected and
an error status code or SOAP fault will be sent to the sender. 
&lt;li&gt;
&lt;strong&gt;DiscardIncomingMessage&lt;/strong&gt; – The sender will get an indication that the
message has been accepted, but the message will be dropped on the floor. 
&lt;li&gt;
&lt;strong&gt;DiscardExistingMessage&lt;/strong&gt; – The Queue will remove and discard messages
from the head of the Queue until the new, incoming message fits in the Queue.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
&lt;strong&gt;PoisonMessageDrop&lt;/strong&gt; – &lt;font color=#ff8000&gt;[this setting not supported
in the March 2009 CTP]&lt;/font&gt; This value is a WS-Addressing 1.0 EndpointReference
referring to an endpoint that any poison messages will be sent to once the &lt;strong&gt;MaxDequeueRetries&lt;/strong&gt; limit
has been exceeded. The EndpointReference may point to any SOAP or plain HTTP endpoint
that can accept ‘any’ message. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Phew! Lots of options. The good thing is that most apps should be ok with the defaults. 
&lt;/p&gt;
&lt;p&gt;
I know that the 2MB capacity limit is somewhat disappointing and I’m certainly not
happy with it. There’s a particular behavior (with bug number) that may occur under
very rare circumstances in the underlying replication system, which caused us to play
it very safe instead of risking data loss. I don’t think the limit is a showstopper
for apps that send notifications and events around – it is a showstopper for apps
that want to exchange larger payloads and we’re working to relax that limit and make
Queues much, much larger as soon as we can. You can obviously always spool larger
data into SDS or one of the Azure storage systems and then send a reference to that
data as a message, but it’d be strange for a messaging system to make that a required
pattern for data of all sizes. If we’re talking hundreds of megabytes it makes sense,
though.
&lt;/p&gt;
&lt;p&gt;
With the due apology out of the way, let’s look at how a policy may be applied to
a namespace name – or in other words, how a queue is created in the simplest case
(this must be done via HTTPS). The model here is that the client &lt;em&gt;proposes&lt;/em&gt; a
policy and Service Bus is at liberty to adjust the policy. 
&lt;/p&gt;
&lt;p&gt;
If you are intimately familiar with Atom, you’ll notice that the &amp;lt;QueuePolicy&amp;gt;
is an extension and isn’t carried as &amp;lt;content&amp;gt;. That’s by intent. &amp;lt;content&amp;gt;
is for people, extensions are for apps. We’ll start using &amp;lt;content&amp;gt; in a later
milestone, so consider that being &lt;em&gt;reserved&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;strong&gt;HTTP/1.1 POST /myapp/q1&lt;br&gt;
Host: clemensv.servicebus.windows.net&lt;br&gt;
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==&lt;br&gt;
Content-Type: application/atom+xml;type=entry;charset=utf-8&lt;br&gt;
Content-Length: nnn&lt;br&gt;
&lt;br&gt;
&amp;lt;entry xmlns=”&lt;em&gt;http://www.w3.org/2005/Atom&lt;/em&gt;”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;QueuePolicy xmlns=”&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;http://schemas.microsoft.com/ws/2007/08/connect”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExpirationInstant&amp;gt;2009-04-03T12:00:00&amp;lt;/ExpirationInstant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/QueuePolicy&amp;gt; &lt;/em&gt;
&lt;br&gt;
&amp;lt;/entry&amp;gt;&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
If the queue can be created, the response is a 200 and you get the policy back along
with any adjustments that the service may make. This is called the “effective” policy,
i.e. that’s what the server is using. You also learn about where you can modify the
policy, since – &lt;a href="http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx"&gt;as
I explained before&lt;/a&gt; – the endpoint where you POST the policy to is morphing into
the Queue’s tail.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;strong&gt;HTTP/1.1 200 OK&lt;br&gt;
Location: https://project-name.servicebus.windows.net/myapp/q1!(queue)&lt;br&gt;
Content-Type: application/atom+xml;type=entry;charset=utf-8&lt;br&gt;
Content-Length: nnn&lt;br&gt;
&lt;br&gt;
&amp;lt;entry xmlns=”&lt;em&gt;http://www.w3.org/2005/Atom&lt;/em&gt;”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”self” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue)”
/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”alternate” href=”https://project-name.servicebus.windows.net/myapp/q1”
/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”queuehead” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue/head)”
/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;QueuePolicy xmlns=”&lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;&lt;em&gt;http://schemas.microsoft.com/ws/2007/08/connect”
&amp;gt;&lt;br&gt;
&lt;/em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExpirationInstant&amp;gt;2009-04-03T12:00:00&amp;lt;/ExpirationInstant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MaxQueueCapacity&amp;gt;2097152&amp;lt;/MaxQueueCapacity&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/QueuePolicy&amp;gt;&lt;br&gt;
&amp;lt;/entry&amp;gt;&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
If you want to renew the Queue (extend the expiration), take the effective policy,
adjust ExpirationInstant and do a PUT to the “self” location. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font face="Courier New"&gt;HTTP/1.1 PUT /myapp/q1&lt;font color=#ff0000&gt;!(queue)&lt;/font&gt;
&lt;br&gt;
Host: project-name.servicebus.windows.net&lt;br&gt;
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==&lt;br&gt;
Content-Type: application/atom+xml;type=entry;charset=utf-8&lt;br&gt;
Content-Length: nnn&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/strong&gt;&lt;strong&gt;&lt;font face="Courier New"&gt;&amp;lt;entry xmlns=”&lt;em&gt;http://www.w3.org/2005/Atom&lt;/em&gt;”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”self” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue)”
/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”alternate” href=”https://project-name.servicebus.windows.net/myapp/q1”
/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”queuehead” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue/head)”
/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;QueuePolicy xmlns=”&lt;/font&gt;&lt;/strong&gt;&lt;strong&gt;&lt;font face="Courier New"&gt;&lt;em&gt;http://schemas.microsoft.com/ws/2007/08/connect”
&amp;gt;&lt;br&gt;
&lt;/em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExpirationInstant&amp;gt;&lt;font color=#ff0000&gt;2009-04-04T12:00:00&lt;/font&gt;&amp;lt;/ExpirationInstant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MaxQueueCapacity&amp;gt;2097152&amp;lt;/MaxQueueCapacity&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/QueuePolicy&amp;gt;&lt;br&gt;
&amp;lt;/entry&amp;gt;&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
[&lt;strong&gt;&lt;font color=#008080&gt;Bug note:&lt;/font&gt;&lt;/strong&gt; The PUT will return the new
effective policy just like the POST response shown above, but the returned Atom &amp;lt;links&amp;gt;
aren’t correctly formed. Keep the ones returned from the POST]
&lt;/p&gt;
&lt;p&gt;
If you want to delete the queue, just nuke the policy:
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font face="Courier New"&gt;HTTP/1.1 DELETE /myapp/q1&lt;font color=#ff0000&gt;!(queue)&lt;/font&gt;
&lt;br&gt;
Host: project-name.servicebus.windows.net&lt;br&gt;
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==&lt;br&gt;
Content-Length: 0&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
So that’s the policy story for Queues. In the next posts I’ll discuss the REST Queue
protocol and the SOAP Queue protocol for how you send message to the queue and get
messages out. REST I’ll explain in protocol terms, the SOAP model in .NET programming
model terms. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=0f64f592-7239-42fc-aed2-f0993701c5f6" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=8e30d2eb-6e2d-4dc5-8aba-5aa410e450de</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=8e30d2eb-6e2d-4dc5-8aba-5aa410e450de</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p align="justify">
In the March 2009 CTP of the .NET Service Bus we’ve added two significant new capabilities,
Routers and Queues, that also signal a change of how we’ve thinking about the Service
Bus namespace, its capabilities and the road ahead. Before the M5 release, the Service
Bus’ primary capability was to act as a Relay between two parties. It’ll absolutely
continue to play that role and we’re working to improve that capability further.
</p>
        <p align="justify">
The significant shift we’ve made with M5 is that we’ve now started to add long-lived,
system-inherent messaging primitives that exist and operate completely independent
of any active listener that sits somewhere on some machine and is plugged into the
Service Bus. That means that you can now leverage the Service Bus as an intermediary
for push-pull translation, or as a publish/subscribe message distribution facility
to optimize or facilitate messaging between places that are already “on the Web” or
you can set up message distribution scenarios where some messaging destinations are
existing Web Services and some receivers require the Service Bus’ relay capability
to be reachable.
</p>
        <p align="justify">
Before I go into further detail on that, let me explain some of the more philosophical
aspects of the model behind Routers and Queues and especially how it relates to the
Service Bus namespace that I’ve <a href="http://blogs.msdn.com/clemensv/archive/2009/03/31/net-services-march-2009-ctp-ndash-the-service-bus-namespace.aspx">already
discussed to some degree in this post</a>. <a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/723.NETServicesMarch2009CTPRoutersandQue_DCB4/image_7.png"><img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 10px 0px 10px 10px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" align="right" src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/723.NETServicesMarch2009CTPRoutersandQue_DCB4/image_thumb_2.png" width="500" height="394" /></a></p>
        <h5>Names and Policies
</h5>
        <p align="justify">
The relationship between any messaging primitive and the Service Bus namespace is
established by picking a <strong><font color="#ff0000">name</font></strong> in your
project’s Service Bus hierarchy - say <strong><a href="https://clemensv.servicebus.windows.net/myapp/q1">https://clemensv.servicebus.windows.net/myapp/<font color="#ff0000">q1
</font></a> – </strong>and then assign a role to that name. From an astronaut’s perspective,
all names in a Service Bus namespace that can theoretically exist do already exist
and their role is ‘none’. So when I’m assigning a role to a name, I don’t create the
name itself. The name is already there, it’s just in hiding. 
</p>
        <p align="justify">
That mind-trick is necessary, because we don’t want to burden anyone with creating
intermediary names leading up to a name in the hierarchy. In the example I’m using
here I would have to first create ‘myapp’ and then create ‘q1’ if we wouldn’t be operating
under the assumption that all names you could ever interact with were already existing. 
</p>
        <p align="justify">
Assigning a role is commonly done using the Atom Publishing Protocol (there’s also
a WS-Transfer head that we use for the .NET SDK bits) whereby the POSTed entry contains
some form of policy that holds information about what role the name should take on,
and what the applicable constraints or operational parameters are. The POST request
is sent to the exact URI projection of the name you picked. 
</p>
        <p align="justify">
Why is that a POST and not a PUT when you already know the URI? 
</p>
        <p align="justify">
Because once you post a policy to a name, there’s a metamorphosis happening (think
“magic little puff of smoke”, not Kafka) that transforms the name into an active messaging
primitive. On success, the POST request will yield a 201 response code along with
a Location header that indicates the place where you’ll further interact with the
policy you just posted. The URI itself is taken over by the primitive.  
</p>
        <p align="justify">
The picture on the right shows what happens in the case of a queue. As the policy
is applied, the queue’s “tail” takes over the URI and two subordinate URIs are created,
whereby one serves to interact with the policy and the other one to dequeue messages
from the queue’s “head”.
</p>
        <p align="justify">
Any name can play any role that’s supported by the system. We currently have a “metadata”
role where you just stick an external reference such as a URI or a WS-Address endpoint
reference into the name in the registry. We have a “connection point” role that’s
established by the WCF listeners as they take over a name to listen on the Service
Bus. And we’ve got these two new roles “queue” and “router” that I’m going to explain
here.
</p>
        <h5>Queues and Routers
</h5>
        <p align="justify">
A Router is a publish/subscribe message distribution primitive that allows “push”
subscribers to subscribe and get messages that flow into the Router. A Queue is a
– well – a queue that accepts messages and holds them until (a) consumer(s) come by
and “pull” the messages off the queue. We’re explicitly allowing for Routers to subscribe
to Routers and for Queues to subscribe into Routers. The resulting composite is typically
quite a bit more powerful than any of the primitives alone. So we call the these capabilities
“primitives”, because they explicitly allow for composition. 
</p>
        <p align="justify">
          <a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/723.NETServicesMarch2009CTPRoutersandQue_DCB4/image_9.png">
            <img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 10px 20px 10px 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" align="left" src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/723.NETServicesMarch2009CTPRoutersandQue_DCB4/image_thumb_3.png" width="500" height="325" />
          </a>In
the picture on the left you see one possible composition pattern. 
</p>
        <p align="justify">
We’ve got a number of processing services that we want to load balance jobs across.
We also have an auditing service that ought to see and log every single “raw” job
message that goes into the system. 
</p>
        <p align="justify">
The audit service is particularly interested in not losing any messages until they
are secured on disk, while the processing services want to get their work pushed to
them and run as fast as they can.
</p>
        <p align="justify">
The setup is that we’re creating a Router with a message distribution policy of “All”
that sends each message to all subscribers. Then we create a secondary Router with
a distribution policy of “One”, which sends any incoming message to exactly one randomly
selected current subscriber – which solves the load balancing problem for the Processing
Service.
</p>
        <p align="justify">
For auditing, we also create a Queue that subscribes into the top-level Router that
gets all messages and holds them for the Audit Service to pick them up. 
</p>
        <p align="justify">
The Audit Service would use the peek/lock pattern to get the messages off the queue.
That means that the consumer puts an exclusive lock on the message that’s being retrieved
and that the message is removed from the view of any competing consumers. The message
isn’t gone, though. If the consumer doesn’t acknowledge the message within a minute,
the message pops back into view. That means that if the Audit Services were to gets
a message but would fumbles it or can’t get it on disk, the message wouldn’t be lost,
even in the case of a catastrophic failure. Once the Audit Service can get the message
on disk, it deletes the lock and that finally removes the message from the Queue.
</p>
        <p align="justify">
So that’s the background on the relationship of Names and Policies and Queues and
Routers and how they are designed for composition. In the next posts I’ll go into
detail on what the policies for Queues and Routers look like, how you apply them via
the SDK programming model or via plain HTTP and how you submit messages into and get
messages out of a Router, a Queue or a composite like the one shown here.
</p>
        <p>
 
</p>
        <p>
 
</p>
        <p>
          <strong>
            <font size="2">
            </font>
          </strong>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=8e30d2eb-6e2d-4dc5-8aba-5aa410e450de" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers and Queues - Part 1: Fundamentals</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/02/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+1+Fundamentals.aspx</link>
      <pubDate>Thu, 02 Apr 2009 01:25:18 GMT</pubDate>
      <description>&lt;p align=justify&gt;
In the March 2009 CTP of the .NET Service Bus we’ve added two significant new capabilities,
Routers and Queues, that also signal a change of how we’ve thinking about the Service
Bus namespace, its capabilities and the road ahead. Before the M5 release, the Service
Bus’ primary capability was to act as a Relay between two parties. It’ll absolutely
continue to play that role and we’re working to improve that capability further.
&lt;/p&gt;
&lt;p align=justify&gt;
The significant shift we’ve made with M5 is that we’ve now started to add long-lived,
system-inherent messaging primitives that exist and operate completely independent
of any active listener that sits somewhere on some machine and is plugged into the
Service Bus. That means that you can now leverage the Service Bus as an intermediary
for push-pull translation, or as a publish/subscribe message distribution facility
to optimize or facilitate messaging between places that are already “on the Web” or
you can set up message distribution scenarios where some messaging destinations are
existing Web Services and some receivers require the Service Bus’ relay capability
to be reachable.
&lt;/p&gt;
&lt;p align=justify&gt;
Before I go into further detail on that, let me explain some of the more philosophical
aspects of the model behind Routers and Queues and especially how it relates to the
Service Bus namespace that I’ve &lt;a href="http://blogs.msdn.com/clemensv/archive/2009/03/31/net-services-march-2009-ctp-ndash-the-service-bus-namespace.aspx"&gt;already
discussed to some degree in this post&lt;/a&gt;. &lt;a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/723.NETServicesMarch2009CTPRoutersandQue_DCB4/image_7.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 10px 0px 10px 10px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image align=right src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/723.NETServicesMarch2009CTPRoutersandQue_DCB4/image_thumb_2.png" width=500 height=394&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;h5&gt;Names and Policies
&lt;/h5&gt;
&lt;p align=justify&gt;
The relationship between any messaging primitive and the Service Bus namespace is
established by picking a &lt;strong&gt;&lt;font color=#ff0000&gt;name&lt;/font&gt;&lt;/strong&gt; in your
project’s Service Bus hierarchy - say &lt;strong&gt;&lt;a href="https://clemensv.servicebus.windows.net/myapp/q1"&gt;https://clemensv.servicebus.windows.net/myapp/&lt;font color=#ff0000&gt;q1
&lt;/a&gt;&gt; – &lt;/strong&gt;and then assign a role to that name. From an astronaut’s perspective,
all names in a Service Bus namespace that can theoretically exist do already exist
and their role is ‘none’. So when I’m assigning a role to a name, I don’t create the
name itself. The name is already there, it’s just in hiding. 
&lt;/p&gt;
&lt;p align=justify&gt;
That mind-trick is necessary, because we don’t want to burden anyone with creating
intermediary names leading up to a name in the hierarchy. In the example I’m using
here I would have to first create ‘myapp’ and then create ‘q1’ if we wouldn’t be operating
under the assumption that all names you could ever interact with were already existing. 
&lt;/p&gt;
&lt;p align=justify&gt;
Assigning a role is commonly done using the Atom Publishing Protocol (there’s also
a WS-Transfer head that we use for the .NET SDK bits) whereby the POSTed entry contains
some form of policy that holds information about what role the name should take on,
and what the applicable constraints or operational parameters are. The POST request
is sent to the exact URI projection of the name you picked. 
&lt;/p&gt;
&lt;p align=justify&gt;
Why is that a POST and not a PUT when you already know the URI? 
&lt;/p&gt;
&lt;p align=justify&gt;
Because once you post a policy to a name, there’s a metamorphosis happening (think
“magic little puff of smoke”, not Kafka) that transforms the name into an active messaging
primitive. On success, the POST request will yield a 201 response code along with
a Location header that indicates the place where you’ll further interact with the
policy you just posted. The URI itself is taken over by the primitive.&amp;nbsp; 
&lt;/p&gt;
&lt;p align=justify&gt;
The picture on the right shows what happens in the case of a queue. As the policy
is applied, the queue’s “tail” takes over the URI and two subordinate URIs are created,
whereby one serves to interact with the policy and the other one to dequeue messages
from the queue’s “head”.
&lt;/p&gt;
&lt;p align=justify&gt;
Any name can play any role that’s supported by the system. We currently have a “metadata”
role where you just stick an external reference such as a URI or a WS-Address endpoint
reference into the name in the registry. We have a “connection point” role that’s
established by the WCF listeners as they take over a name to listen on the Service
Bus. And we’ve got these two new roles “queue” and “router” that I’m going to explain
here.
&lt;/p&gt;
&lt;h5&gt;Queues and Routers
&lt;/h5&gt;
&lt;p align=justify&gt;
A Router is a publish/subscribe message distribution primitive that allows “push”
subscribers to subscribe and get messages that flow into the Router. A Queue is a
– well – a queue that accepts messages and holds them until (a) consumer(s) come by
and “pull” the messages off the queue. We’re explicitly allowing for Routers to subscribe
to Routers and for Queues to subscribe into Routers. The resulting composite is typically
quite a bit more powerful than any of the primitives alone. So we call the these capabilities
“primitives”, because they explicitly allow for composition. 
&lt;/p&gt;
&lt;p align=justify&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/723.NETServicesMarch2009CTPRoutersandQue_DCB4/image_9.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 10px 20px 10px 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image align=left src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/723.NETServicesMarch2009CTPRoutersandQue_DCB4/image_thumb_3.png" width=500 height=325&gt;&lt;/a&gt;In
the picture on the left you see one possible composition pattern. 
&lt;/p&gt;
&lt;p align=justify&gt;
We’ve got a number of processing services that we want to load balance jobs across.
We also have an auditing service that ought to see and log every single “raw” job
message that goes into the system. 
&lt;/p&gt;
&lt;p align=justify&gt;
The audit service is particularly interested in not losing any messages until they
are secured on disk, while the processing services want to get their work pushed to
them and run as fast as they can.
&lt;/p&gt;
&lt;p align=justify&gt;
The setup is that we’re creating a Router with a message distribution policy of “All”
that sends each message to all subscribers. Then we create a secondary Router with
a distribution policy of “One”, which sends any incoming message to exactly one randomly
selected current subscriber – which solves the load balancing problem for the Processing
Service.
&lt;/p&gt;
&lt;p align=justify&gt;
For auditing, we also create a Queue that subscribes into the top-level Router that
gets all messages and holds them for the Audit Service to pick them up. 
&lt;/p&gt;
&lt;p align=justify&gt;
The Audit Service would use the peek/lock pattern to get the messages off the queue.
That means that the consumer puts an exclusive lock on the message that’s being retrieved
and that the message is removed from the view of any competing consumers. The message
isn’t gone, though. If the consumer doesn’t acknowledge the message within a minute,
the message pops back into view. That means that if the Audit Services were to gets
a message but would fumbles it or can’t get it on disk, the message wouldn’t be lost,
even in the case of a catastrophic failure. Once the Audit Service can get the message
on disk, it deletes the lock and that finally removes the message from the Queue.
&lt;/p&gt;
&lt;p align=justify&gt;
So that’s the background on the relationship of Names and Policies and Queues and
Routers and how they are designed for composition. In the next posts I’ll go into
detail on what the policies for Queues and Routers look like, how you apply them via
the SDK programming model or via plain HTTP and how you submit messages into and get
messages out of a Router, a Queue or a composite like the one shown here.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font size=2&gt;&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=8e30d2eb-6e2d-4dc5-8aba-5aa410e450de" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx</comments>
      <category>.NET Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=634b72d9-e200-45de-82db-2ae4c8ef947e</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,634b72d9-e200-45de-82db-2ae4c8ef947e.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,634b72d9-e200-45de-82db-2ae4c8ef947e.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=634b72d9-e200-45de-82db-2ae4c8ef947e</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>… <a href="http://de.wikipedia.org/wiki/Auf_der_Mauer,_auf_der_Lauer">seht Euch
mal die Wa an, wie die Wa ta kann. Auf der Mauer auf der Lauer sitzt ‘ne kleine Wa!</a>.</em>
        </p>
        <p>
It’s a German children’s song. The song starts out with “… sitzt ‘ne kleine Wanze”
(bedbug) and with each verse you leave off a letter: Wanz, Wan, Wa, W, – silence. 
</p>
        <p>
I’ll do the same here, but not with a bedbug:
</p>
        <p>
Let’s sing:
</p>
        <p>
          <font face="Courier New">&lt;soap:Envelope xmlns:soap=”” xmlns:wsaddr=”” xmlns:wsrm=””
xmlns:wsu=”” xmlns:app=””&gt;<br />
   &lt;soap:Header&gt;<br />
         &lt;addr:Action&gt;http://tempuri.org/1.0/Status.set&lt;/addr:Action&gt;<br />
         &lt;wsrm:Sequence&gt;<br />
              &lt;wsrm:Identifier&gt;urn:session-id&lt;/wsrm:Identifier&gt;<br />
              &lt;wsrm:MessageNumber&gt;5&lt;/wsrm:MessageNumber&gt;<br />
          &lt;/wsrm:Sequence&gt;<br />
          &lt;wsse:Security xmlns:wsse=”…”&gt;<br />
              
&lt;wsse:BinarySecurityToken ValueType="</font>
          <font face="Courier New">http://tempuri.org#CustomToken</font>
          <font face="Courier New">" 
<br />
                                        
EncodingType="...#Base64Binary" wsu:Id=" MyID "&gt;<br />
                         
FHUIORv...<br />
               
&lt;/wsse:BinarySecurityToken&gt;<br />
              
&lt;ds:Signature&gt;<br />
                 
&lt;ds:SignedInfo&gt; 
<br />
                     
&lt;ds:CanonicalizationMethod Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;</font>
          <br />
          <font face="Courier New">                     
&lt;ds:SignatureMethod Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#md5"/</font>
          <font face="Courier New">&gt;  
<br />
                     
&lt;ds:Reference URI="#MsgBody"&gt;<br />
                           
&lt;ds:DigestMethod  Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#md5"/&gt;</font>
          <font face="Courier New"> <br />
                           
&lt;ds:DigestValue&gt;LyLsF0Pi4wPU...&lt;/ds:DigestValue&gt;<br />
                     
&lt;/ds:Reference&gt;<br />
                
&lt;/ds:SignedInfo&gt;   
<br />
                
&lt;ds:SignatureValue&gt;DJbchm5gK...&lt;/ds:SignatureValue&gt; 
<br />
                
&lt;ds:KeyInfo&gt;  
<br />
                 
&lt;wsse:SecurityTokenReference&gt;  
<br />
                   
&lt;wsse:Reference URI="#MyID"/&gt; 
<br />
                  
&lt;/wsse:SecurityTokenReference&gt; 
<br />
              
&lt;/ds:KeyInfo&gt; 
<br />
             &lt;/ds:Signature&gt;<br />
         &lt;/wsse:Security&gt;<br />
         &lt;app:ResponseFormat&gt;Xml&lt;/app:ResponseFormat&gt;<br />
         &lt;app:Key wsu:Id=”AppKey”&gt;27729912882….&lt;/app:Key&gt; 
<br />
    &lt;soap:Header&gt;<br />
    &lt;soap:Body wsu:Id=”MyId”&gt;<br />
          &lt;app:status&gt;Hello, I’m
good&lt;/app:status&gt;<br />
     &lt;/soap:Body&gt;<br />
&lt;/soap:Envelope&gt; </font>
        </p>
        <p>
Not a very pretty song, I’ll admit. Let’s drop a some stuff. Let’s assume that we
don’t need to tell the other party that we’re looking to give it an MD5 signature,
but let’s say that’s implied and so were the canonicalization algorithm. Let’s also
assume that the other side already knows the security token and the key. Since we
only have a single signature digest here and yield a single signature we can just
collapse to the signature value. Heck, you may not even know about what that all means.
Verse 2:
</p>
        <p>
          <font face="Courier New">&lt;soap:Envelope xmlns:soap=”” xmlns:wsaddr=”” xmlns:wsrm=””
xmlns:wsu=”” xmlns:app=””&gt;<br />
   &lt;soap:Header&gt;<br />
         &lt;addr:Action&gt;http://tempuri.org/1.0/Status.set&lt;/addr:Action&gt;<br />
         &lt;wsrm:Sequence&gt;<br />
              &lt;wsrm:Identifier&gt;urn:session-id&lt;/wsrm:Identifier&gt;<br />
              &lt;wsrm:MessageNumber&gt;5&lt;/wsrm:MessageNumber&gt;<br />
          &lt;/wsrm:Sequence&gt;<br />
          &lt;wsse:Security xmlns:wsse=”…”&gt;<br />
              
&lt;ds:Signature&gt;<br />
                 
&lt;ds:SignatureValue&gt;DJbchm5gK...&lt;/ds:SignatureValue&gt; 
<br />
             &lt;/ds:Signature&gt;<br />
         &lt;/wsse:Security&gt;<br />
         &lt;app:ResponseFormat&gt;Xml&lt;/app:ResponseFormat&gt;<br />
         &lt;app:Key wsu:Id=”AppKey”&gt;27729912882….&lt;/app:Key&gt; 
<br />
    &lt;soap:Header&gt;<br />
    &lt;soap:Body wsu:Id=”MyId”&gt;<br />
          &lt;app:status&gt;Hello, I’m
good&lt;/app:status&gt;<br />
     &lt;/soap:Body&gt;<br />
&lt;/soap:Envelope&gt; </font>
        </p>
        <p>
Better. Now let’s strip all these extra XML namespace decorations since there aren’t
any name collisions as far as I can see. We’ll also collapse the rest of the security
elements into one element since there’s no need for three levels of nesting with a
single signature. Verse 3:
</p>
        <p>
          <font face="Courier New">&lt;Envelope&gt;<br />
   &lt;Header&gt;<br />
         &lt;Action&gt;http://tempuri.org/1.0/Status.set&lt;/Action&gt;<br />
         &lt;Sequence&gt;<br />
              &lt;Identifier&gt;urn:session-id&lt;/Identifier&gt;<br />
              &lt;MessageNumber&gt;5&lt;/MessageNumber&gt;<br />
          &lt;/Sequence&gt;<br />
          &lt;SignatureValue&gt;DJbchm5gK...&lt;/SignatureValue&gt;<br />
          &lt;ResponseFormat&gt;Xml&lt;/ResponseFormat&gt;<br />
          &lt;Key&gt;27729912882….&lt;/Key&gt; 
<br />
    &lt;Header&gt;<br />
    &lt;Body&gt;<br />
       &lt;status&gt;Hello, I’m good&lt;/status&gt;<br />
     &lt;/Body&gt;<br />
&lt;/Envelope&gt; </font>
        </p>
        <p>
Much better. The whole angle-bracket stuff and the nesting seems semi-gratuitous and
repetitive here, too. Let’s make that a bit simpler. Verse 4:
</p>
        <p>
          <font face="Courier New">         Action=http://tempuri.org/1.0/Status.set<br />
         Sequence-Identifier=urn:session-id<br />
         Sequence-MessageNumber=5<br />
         SignatureValue=DJbchm5gK...<br />
         ResponseFormat=Xml<br />
         Key=27729912882…. 
<br />
         status=Hello, I’m good</font>
        </p>
        <p>
Much, much better. Now let’s get rid of that weird URI up there and split up the action
and the version info, make some of these keys are little more terse and turn that
into a format that’s easily transmittable over HTTP. By what we have here application/www-form-urlencoded
would probably be best. Verse 5:
</p>
        <p>
          <font face="Courier New">         method=Status.set<br />
         &amp;v=1.0<br />
         &amp;session_key=929872172..<br />
         &amp;call_id=5<br />
         &amp;sig=DJbchm5gK...<br />
         &amp;format=Xml<br />
         &amp;api_key=27729912882…. 
<br />
         &amp;status=Hello,%20I’m%20good</font>
        </p>
        <p>
Oops. <a href="http://wiki.developers.facebook.com/index.php/Status.set">Facebook</a>’s
Status.set API. How did that happen? I thought that was REST?
</p>
        <p>
Now play the song backwards. The “new thing” is largely analogous to where we started
before the WS* Web Services stack and its CORBA/DCE/DCOM predecessors came around
and there are, believe it or not, good reasons for having of that additional “overhead”.
A common way to frame message content and the related control data, a common way to
express complex data structures and distinguish between data domains, a common way
to deal with addressing in multi-hop or store-and-forward messaging scenarios, an
agreed notion of sessions and message sequencing, a solid mechanism for protecting
the integrity of messages and parts of messages. This isn’t all just stupid.
</p>
        <p>
It’s well worth discussing whether messages need to be expressed as XML 1.0 text on
the wire at all times. I don’t think they need to and there are alternatives that
aren’t as heavy. JSON is fine and encodings like the .NET Binary Encoding or Fast
Infoset are viable alternatives as well. It’s also well worth discussing whether WS-Security
and the myriad of related standards that were clearly built by security geniuses for
security geniuses really need to be that complicated or whether we could all live
with a handful of simple profiles and just cut out 80% of the options and knobs and
parameters in that land. 
</p>
        <p>
I find it very sad that the discussion isn’t happening. Instead, people use the “REST”
moniker as the escape hatch to conveniently ignore any existing open standard for
tunnel-through-HTTP messaging and completely avoid the discussion. 
</p>
        <p>
It’s not only sad, it’s actually a bit frustrating. As one of the people responsible
for the protocol surface of the .NET Service Bus, I am absolutely not at liberty to
ignore what exists in the standards space. And this isn’t a mandate handed down to
me, but something I do because I believe it’s the right thing to live with the constraints
of the standards frameworks that exist. 
</p>
        <p>
When we’re sitting down and talk about a REST API, were designing a set of resources
– which may result in splitting a thing like a queue into two resources, head and
tail - and then we put RFC2616 on the table and try to be very precise in picking
the appropriate predefined HTTP method for a given semantic and how the HTTP 2xx,
3xx, 4xx, 5xx status codes map to success and error conditions. We’re also trying
to avoid inventing new ways to express things for which standards exists. There’s
a standard for how to express and manage lists with ATOM and APP and hence we use
that as a foundation. We use the designed extension points to add data to those lists
whenever necessary.
</p>
        <p>
When we’re designing a <strike>RPC</strike> SOAP API, we’re intentionally trying to
avoid inventing new protocol surface and will try to leverage as much from the existing
and standardized stack as we possibly can – at a minimum we’ll stick with established
patterns such as the Create/GetInfo/Renew/Delete patterns for endpoint factories with
renewal (which is used in several standards). I’ll add that we are – ironically -
a bit backlogged on the protocol documentation for our SOAP endpoints and have more
info on the REST endpoint in the latest SDK, but we’ll make that up in the near future.
</p>
        <p>
So - can I build “REST” (mind the quotes) protocols that are as reduced as Facebook,
Twitter, Flickr, etc? Absolutely. There wouldn’t be much new work. It’s just a matter
of how we put messages on and pluck message off the wire. It’s really mostly a matter
of formatting and we have a lot of the necessary building blocks in the shipping WCF
bits today. I would just omit a bunch of decoration as things go out and make a bunch
of assumptions on things that come in.
</p>
        <p>
I just have a sense that I’d be hung upside down from a tree by the press and the
blogging, twittering, facebooking community if I, as someone at Microsoft, wouldn’t
follow the existing open and agreed standards or at least use protocols that we’ve
published under the <a href="http://www.microsoft.com/interop/osp/default.mspx">OSP</a> and
instead just started to do my own interpretative dance - even if that looked strikingly
similar to what the folks down in the Valley are doing. At the very least, someone
would call it a rip-off.
</p>
        <p>
What do you think? What should I/we do? 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=634b72d9-e200-45de-82db-2ae4c8ef947e" />
      </body>
      <title>[Intermission] Auf der Mauer, auf der Lauer sitzt 'ne kleine Wa! - or: When REST isn't REST - or: Why and How I Care About Standards-Compliance</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,634b72d9-e200-45de-82db-2ae4c8ef947e.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/01/Intermission+Auf+Der+Mauer+Auf+Der+Lauer+Sitzt+Ne+Kleine+Wa+Or+When+REST+Isnt+REST+Or+Why+And+How+I+Care+About+StandardsCompliance.aspx</link>
      <pubDate>Wed, 01 Apr 2009 17:40:41 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;… &lt;a href="http://de.wikipedia.org/wiki/Auf_der_Mauer,_auf_der_Lauer"&gt;seht Euch
mal die Wa an, wie die Wa ta kann. Auf der Mauer auf der Lauer sitzt ‘ne kleine Wa!&lt;/a&gt;.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
It’s a German children’s song. The song starts out with “… sitzt ‘ne kleine Wanze”
(bedbug) and with each verse you leave off a letter: Wanz, Wan, Wa, W, – silence. 
&lt;/p&gt;
&lt;p&gt;
I’ll do the same here, but not with a bedbug:
&lt;/p&gt;
&lt;p&gt;
Let’s sing:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;soap:Envelope xmlns:soap=”” xmlns:wsaddr=”” xmlns:wsrm=””
xmlns:wsu=”” xmlns:app=””&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;soap:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;addr:Action&amp;gt;http://tempuri.org/1.0/Status.set&amp;lt;/addr:Action&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:Identifier&amp;gt;urn:session-id&amp;lt;/wsrm:Identifier&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:MessageNumber&amp;gt;5&amp;lt;/wsrm:MessageNumber&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsse:Security xmlns:wsse=”…”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;wsse:BinarySecurityToken ValueType="&lt;/font&gt;&lt;font face="Courier New"&gt;http://tempuri.org#CustomToken&lt;/font&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
EncodingType="...#Base64Binary" wsu:Id=" MyID "&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
FHUIORv...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/wsse:BinarySecurityToken&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:Signature&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:SignedInfo&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:CanonicalizationMethod Algorithm="&lt;/font&gt;&lt;font face="Courier New"&gt;http://www.w3.org/2001/10/xml-exc-c14n#"/&amp;gt;&lt;/font&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:SignatureMethod Algorithm="&lt;/font&gt;&lt;font face="Courier New"&gt;http://www.w3.org/2000/09/xmldsig#md5"/&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;gt;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:Reference URI="#MsgBody"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:DigestMethod&amp;nbsp; Algorithm="&lt;/font&gt;&lt;font face="Courier New"&gt;http://www.w3.org/2000/09/xmldsig#md5"/&amp;gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:DigestValue&amp;gt;LyLsF0Pi4wPU...&amp;lt;/ds:DigestValue&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/ds:Reference&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/ds:SignedInfo&amp;gt;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:SignatureValue&amp;gt;DJbchm5gK...&amp;lt;/ds:SignatureValue&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:KeyInfo&amp;gt;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;wsse:SecurityTokenReference&amp;gt;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;wsse:Reference URI="#MyID"/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/wsse:SecurityTokenReference&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/ds:KeyInfo&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ds:Signature&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsse:Security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:ResponseFormat&amp;gt;Xml&amp;lt;/app:ResponseFormat&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:Key wsu:Id=”AppKey”&amp;gt;27729912882….&amp;lt;/app:Key&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;soap:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;soap:Body wsu:Id=”MyId”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:status&amp;gt;Hello, I’m
good&amp;lt;/app:status&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/soap:Body&amp;gt;&lt;br&gt;
&amp;lt;/soap:Envelope&amp;gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Not a very pretty song, I’ll admit. Let’s drop a some stuff. Let’s assume that we
don’t need to tell the other party that we’re looking to give it an MD5 signature,
but let’s say that’s implied and so were the canonicalization algorithm. Let’s also
assume that the other side already knows the security token and the key. Since we
only have a single signature digest here and yield a single signature we can just
collapse to the signature value. Heck, you may not even know about what that all means.
Verse 2:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;soap:Envelope xmlns:soap=”” xmlns:wsaddr=”” xmlns:wsrm=””
xmlns:wsu=”” xmlns:app=””&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;soap:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;addr:Action&amp;gt;http://tempuri.org/1.0/Status.set&amp;lt;/addr:Action&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:Identifier&amp;gt;urn:session-id&amp;lt;/wsrm:Identifier&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:MessageNumber&amp;gt;5&amp;lt;/wsrm:MessageNumber&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsse:Security xmlns:wsse=”…”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:Signature&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:SignatureValue&amp;gt;DJbchm5gK...&amp;lt;/ds:SignatureValue&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ds:Signature&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsse:Security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:ResponseFormat&amp;gt;Xml&amp;lt;/app:ResponseFormat&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:Key wsu:Id=”AppKey”&amp;gt;27729912882….&amp;lt;/app:Key&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;soap:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;soap:Body wsu:Id=”MyId”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:status&amp;gt;Hello, I’m
good&amp;lt;/app:status&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/soap:Body&amp;gt;&lt;br&gt;
&amp;lt;/soap:Envelope&amp;gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Better. Now let’s strip all these extra XML namespace decorations since there aren’t
any name collisions as far as I can see. We’ll also collapse the rest of the security
elements into one element since there’s no need for three levels of nesting with a
single signature. Verse 3:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;Envelope&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Action&amp;gt;http://tempuri.org/1.0/Status.set&amp;lt;/Action&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Identifier&amp;gt;urn:session-id&amp;lt;/Identifier&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MessageNumber&amp;gt;5&amp;lt;/MessageNumber&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SignatureValue&amp;gt;DJbchm5gK...&amp;lt;/SignatureValue&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ResponseFormat&amp;gt;Xml&amp;lt;/ResponseFormat&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Key&amp;gt;27729912882….&amp;lt;/Key&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Body&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;status&amp;gt;Hello, I’m good&amp;lt;/status&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Body&amp;gt;&lt;br&gt;
&amp;lt;/Envelope&amp;gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Much better. The whole angle-bracket stuff and the nesting seems semi-gratuitous and
repetitive here, too. Let’s make that a bit simpler. Verse 4:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Action=http://tempuri.org/1.0/Status.set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sequence-Identifier=urn:session-id&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sequence-MessageNumber=5&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SignatureValue=DJbchm5gK...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResponseFormat=Xml&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Key=27729912882…. 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status=Hello, I’m good&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Much, much better. Now let’s get rid of that weird URI up there and split up the action
and the version info, make some of these keys are little more terse and turn that
into a format that’s easily transmittable over HTTP. By what we have here application/www-form-urlencoded
would probably be best. Verse 5:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; method=Status.set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;v=1.0&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;session_key=929872172..&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;call_id=5&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;sig=DJbchm5gK...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;format=Xml&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;api_key=27729912882…. 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;status=Hello,%20I’m%20good&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Oops. &lt;a href="http://wiki.developers.facebook.com/index.php/Status.set"&gt;Facebook&lt;/a&gt;’s
Status.set API. How did that happen? I thought that was REST?
&lt;/p&gt;
&lt;p&gt;
Now play the song backwards. The “new thing” is largely analogous to where we started
before the WS* Web Services stack and its CORBA/DCE/DCOM predecessors came around
and there are, believe it or not, good reasons for having of that additional “overhead”.
A common way to frame message content and the related control data, a common way to
express complex data structures and distinguish between data domains, a common way
to deal with addressing in multi-hop or store-and-forward messaging scenarios, an
agreed notion of sessions and message sequencing, a solid mechanism for protecting
the integrity of messages and parts of messages. This isn’t all just stupid.
&lt;/p&gt;
&lt;p&gt;
It’s well worth discussing whether messages need to be expressed as XML 1.0 text on
the wire at all times. I don’t think they need to and there are alternatives that
aren’t as heavy. JSON is fine and encodings like the .NET Binary Encoding or Fast
Infoset are viable alternatives as well. It’s also well worth discussing whether WS-Security
and the myriad of related standards that were clearly built by security geniuses for
security geniuses really need to be that complicated or whether we could all live
with a handful of simple profiles and just cut out 80% of the options and knobs and
parameters in that land. 
&lt;/p&gt;
&lt;p&gt;
I find it very sad that the discussion isn’t happening. Instead, people use the “REST”
moniker as the escape hatch to conveniently ignore any existing open standard for
tunnel-through-HTTP messaging and completely avoid the discussion. 
&lt;/p&gt;
&lt;p&gt;
It’s not only sad, it’s actually a bit frustrating. As one of the people responsible
for the protocol surface of the .NET Service Bus, I am absolutely not at liberty to
ignore what exists in the standards space. And this isn’t a mandate handed down to
me, but something I do because I believe it’s the right thing to live with the constraints
of the standards frameworks that exist. 
&lt;/p&gt;
&lt;p&gt;
When we’re sitting down and talk about a REST API, were designing a set of resources
– which may result in splitting a thing like a queue into two resources, head and
tail - and then we put RFC2616 on the table and try to be very precise in picking
the appropriate predefined HTTP method for a given semantic and how the HTTP 2xx,
3xx, 4xx, 5xx status codes map to success and error conditions. We’re also trying
to avoid inventing new ways to express things for which standards exists. There’s
a standard for how to express and manage lists with ATOM and APP and hence we use
that as a foundation. We use the designed extension points to add data to those lists
whenever necessary.
&lt;/p&gt;
&lt;p&gt;
When we’re designing a &lt;strike&gt;RPC&lt;/strike&gt; SOAP API, we’re intentionally trying to
avoid inventing new protocol surface and will try to leverage as much from the existing
and standardized stack as we possibly can – at a minimum we’ll stick with established
patterns such as the Create/GetInfo/Renew/Delete patterns for endpoint factories with
renewal (which is used in several standards). I’ll add that we are – ironically -
a bit backlogged on the protocol documentation for our SOAP endpoints and have more
info on the REST endpoint in the latest SDK, but we’ll make that up in the near future.
&lt;/p&gt;
&lt;p&gt;
So - can I build “REST” (mind the quotes) protocols that are as reduced as Facebook,
Twitter, Flickr, etc? Absolutely. There wouldn’t be much new work. It’s just a matter
of how we put messages on and pluck message off the wire. It’s really mostly a matter
of formatting and we have a lot of the necessary building blocks in the shipping WCF
bits today. I would just omit a bunch of decoration as things go out and make a bunch
of assumptions on things that come in.
&lt;/p&gt;
&lt;p&gt;
I just have a sense that I’d be hung upside down from a tree by the press and the
blogging, twittering, facebooking community if I, as someone at Microsoft, wouldn’t
follow the existing open and agreed standards or at least use protocols that we’ve
published under the &lt;a href="http://www.microsoft.com/interop/osp/default.mspx"&gt;OSP&lt;/a&gt; and
instead just started to do my own interpretative dance - even if that looked strikingly
similar to what the folks down in the Valley are doing. At the very least, someone
would call it a rip-off.
&lt;/p&gt;
&lt;p&gt;
What do you think? What should I/we do? 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=634b72d9-e200-45de-82db-2ae4c8ef947e" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,634b72d9-e200-45de-82db-2ae4c8ef947e.aspx</comments>
      <category>.NET Services</category>
      <category>Architecture</category>
      <category>Azure</category>
      <category>Technology</category>
      <category>Technology/ISB</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>[Update 2010-08-25: Wade Wegner </strong>
          <a href="http://blog.wadewegner.com/2010/05/host-wcf-services-in-iis-with-service-bus-endpoints/">
            <strong>now
shows a solution on his blog</strong>
          </a>
          <strong>]</strong>
        </p>
        <p>
We’ve been getting some questions along the lines of “I am hosting a service as xyz.svc
in IIS and have changed the config to use on of the <a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#Service_Bus_Bindings">Service
Bus bindings</a>, but the service never gets called?”
</p>
        <p>
That’s right. It doesn’t. The reason for that is that we don’t yet have WAS/IIS integration
for any of the <a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#Service_Bus_Bindings">Service
Bus bindings</a> in the November 2008 CTP. Enabling the WCF WAS activation scenario
that puts the <a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#NetTcpRelayBinding">NetTcpRelayBinding</a> and
friends on par with their WCF siblings is on our work backlog for the next major milestone. 
</p>
        <p>
It’s worth considering for a moment what that integration requires. Fundamentally,
all of the Relay bindings replace the local TCP or HTTP listener with a listener that
sits up in the cloud and services then connect up to that listener to create an inbound
route for received messages. That’s similar to how local services interact with WCF’s
shared TCP listener or HTTP.SYS, but there are quite a few important differences.
First, all Relay listeners need to acquire and present an <a href="http://msdn.microsoft.com/en-us/library/dd129876.aspx">Access
Control</a> token when they start listening on the Service Bus. In contrast, the local
listener facilities are ACL’d using the local or domain account system and use the
Windows process identity to decide on whether a process may or may not listen on a
particular port and/or namespace. Second, since the actual listener is off-machine,
we need to spin up the connection as the IIS/WAS host spins up and need to make sure
that the connection is kept alive and aggressively reconnects when dropped for any
reason. That’s something you don’t really have to worry much about when the listener
sits right there on the same machine as your own service and the connection is a named
pipe. Third, the local listeners listen on a particular host address and port; the
Relay listeners listen on a leaf of a namespace tree and that namespace may be shared
amongst many listeners living on a multitude of different machines in different locations. 
Fourth,   ... well you get the picture. 
</p>
        <p>
Bottom line: Not having support for WAS activation and <em>xyz.svc</em> service endpoints
is by no means an oversight. It’s on the list.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43" />
      </body>
      <title>The Service Bus Bindings and WAS/IIS</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43.aspx</guid>
      <link>http://vasters.com/clemensv/2008/11/05/The+Service+Bus+Bindings+And+WASIIS.aspx</link>
      <pubDate>Wed, 05 Nov 2008 23:16:43 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;[Update 2010-08-25: Wade Wegner&amp;nbsp;&lt;/strong&gt;&lt;a href="http://blog.wadewegner.com/2010/05/host-wcf-services-in-iis-with-service-bus-endpoints/"&gt;&lt;strong&gt;now
shows a solution on his blog&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;]&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
We’ve been getting some questions along the lines of “I am hosting a service as xyz.svc
in IIS and have changed the config to use on of the &lt;a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#Service_Bus_Bindings"&gt;Service
Bus bindings&lt;/a&gt;, but the service never gets called?”
&lt;/p&gt;
&lt;p&gt;
That’s right. It doesn’t. The reason for that is that we don’t yet have WAS/IIS integration
for any of the &lt;a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#Service_Bus_Bindings"&gt;Service
Bus bindings&lt;/a&gt; in the November 2008 CTP. Enabling the WCF WAS activation scenario
that puts the &lt;a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#NetTcpRelayBinding"&gt;NetTcpRelayBinding&lt;/a&gt; and
friends on par with their WCF siblings is on our work backlog for the next major milestone. 
&lt;/p&gt;
&lt;p&gt;
It’s worth considering for a moment what that integration requires. Fundamentally,
all of the Relay bindings replace the local TCP or HTTP listener with a listener that
sits up in the cloud and services then connect up to that listener to create an inbound
route for received messages. That’s similar to how local services interact with WCF’s
shared TCP listener or HTTP.SYS, but there are quite a few important differences.
First, all Relay listeners need to acquire and present an &lt;a href="http://msdn.microsoft.com/en-us/library/dd129876.aspx"&gt;Access
Control&lt;/a&gt; token when they start listening on the Service Bus. In contrast, the local
listener facilities are ACL’d using the local or domain account system and use the
Windows process identity to decide on whether a process may or may not listen on a
particular port and/or namespace. Second, since the actual listener is off-machine,
we need to spin up the connection as the IIS/WAS host spins up and need to make sure
that the connection is kept alive and aggressively reconnects when dropped for any
reason. That’s something you don’t really have to worry much about when the listener
sits right there on the same machine as your own service and the connection is a named
pipe. Third, the local listeners listen on a particular host address and port; the
Relay listeners listen on a leaf of a namespace tree and that namespace may be shared
amongst many listeners living on a multitude of different machines in different locations.&amp;nbsp;
Fourth,&amp;nbsp;&amp;nbsp; ... well you get the picture. 
&lt;/p&gt;
&lt;p&gt;
Bottom line: Not having support for WAS activation and &lt;em&gt;xyz.svc&lt;/em&gt; service endpoints
is by no means an oversight. It’s on the list.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=f7500883-e4a6-4697-ad1d-8a8829ec40d9</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,f7500883-e4a6-4697-ad1d-8a8829ec40d9.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,f7500883-e4a6-4697-ad1d-8a8829ec40d9.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=f7500883-e4a6-4697-ad1d-8a8829ec40d9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://msdn.microsoft.com/en-us/azure/netservices.aspx">MSDN Developer
Center for .NET Services</a> is the first stop to go to for technical information
on the Service Bus, the Access Control Service and the Workflow Service. 
</p>
        <p>
There quite a bit of documentation for “my” feature area, the <a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx">.NET
Service Bus</a>, including description of all the bindings and most of the object
model surface area. Since we had quite a bit of object model churn up until a few
weeks before PDC as we’ve exploded the former, singular <em>RelayBinding</em> into
two handful of WCF-aligned bindings, the reference documentation isn’t yet in the
familiar MSDN reference format and also doesn’t yet work with Visual Studio’s “F1”.
We’re obviously going to address that in the next major milestone now that the dust
is settling a bit and the programming model is already quite a bit closer to what
we want it to be for our “V1” release. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=f7500883-e4a6-4697-ad1d-8a8829ec40d9" />
      </body>
      <title>.NET Services: MSDN Developer Center</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,f7500883-e4a6-4697-ad1d-8a8829ec40d9.aspx</guid>
      <link>http://vasters.com/clemensv/2008/11/05/NET+Services+MSDN+Developer+Center.aspx</link>
      <pubDate>Wed, 05 Nov 2008 19:27:31 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://msdn.microsoft.com/en-us/azure/netservices.aspx"&gt;MSDN Developer
Center for .NET Services&lt;/a&gt; is the first stop to go to for technical information
on the Service Bus, the Access Control Service and the Workflow Service. 
&lt;/p&gt;
&lt;p&gt;
There quite a bit of documentation for “my” feature area, the &lt;a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx"&gt;.NET
Service Bus&lt;/a&gt;, including description of all the bindings and most of the object
model surface area. Since we had quite a bit of object model churn up until a few
weeks before PDC as we’ve exploded the former, singular &lt;em&gt;RelayBinding&lt;/em&gt; into
two handful of WCF-aligned bindings, the reference documentation isn’t yet in the
familiar MSDN reference format and also doesn’t yet work with Visual Studio’s “F1”.
We’re obviously going to address that in the next major milestone now that the dust
is settling a bit and the programming model is already quite a bit closer to what
we want it to be for our “V1” release. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=f7500883-e4a6-4697-ad1d-8a8829ec40d9" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,f7500883-e4a6-4697-ad1d-8a8829ec40d9.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=535b30fb-3e2c-442b-9fa2-33adb0f4acb1</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,535b30fb-3e2c-442b-9fa2-33adb0f4acb1.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,535b30fb-3e2c-442b-9fa2-33adb0f4acb1.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=535b30fb-3e2c-442b-9fa2-33adb0f4acb1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the sea of PDC 2008 announcements you may have missed the following two signficant
developments:
</p>
        <ul>
          <li>
            <a href="http://jdotnetservices.com/">.NET Services for Java</a>
          </li>
          <li>
            <a href="http://www.dotnetservicesruby.com/">.NET Services for Ruby</a>
          </li>
        </ul>
        <p>
For the past 2 months our team has worked very closely with our partners at <a href="http://www.schakra.com">Schakra</a> on
the Java SDK parts and with <a href="http://www.thoughtworks.com">ThoughtWorks</a> on
the Ruby parts. These are the first baby steps and these two SDKs cover only
a small subset of the capabilities of the .NET SDK so far. That's merely a function
of when we started with these projects and how far we've gotten with the required
protocol support; we want and we will take this a lot further over the next development
milestones. In the end, the .NET Services fabric ought not to care much what language
the senders and listeners are written in and what platform they run
on. We're building a universal services platform. We're taking Java and Ruby
very seriously and have a few more platforms on the list for which we want to
add explicit support. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=535b30fb-3e2c-442b-9fa2-33adb0f4acb1" />
      </body>
      <title>.NET Services - Two things you may not have noticed yet....</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,535b30fb-3e2c-442b-9fa2-33adb0f4acb1.aspx</guid>
      <link>http://vasters.com/clemensv/2008/11/03/NET+Services+Two+Things+You+May+Not+Have+Noticed+Yet.aspx</link>
      <pubDate>Mon, 03 Nov 2008 05:03:21 GMT</pubDate>
      <description>&lt;p&gt;
In&amp;nbsp;the sea of PDC 2008 announcements you may have missed the following two signficant
developments:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://jdotnetservices.com/"&gt;.NET Services for Java&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.dotnetservicesruby.com/"&gt;.NET Services for Ruby&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
For the past 2 months our team has worked very closely with our partners at &lt;a href="http://www.schakra.com"&gt;Schakra&lt;/a&gt;&amp;nbsp;on
the Java SDK parts and with &lt;a href="http://www.thoughtworks.com"&gt;ThoughtWorks&lt;/a&gt; on
the Ruby parts. These are&amp;nbsp;the first baby steps and these two SDKs cover only
a small subset of the capabilities of the .NET SDK so far. That's&amp;nbsp;merely a function
of when we started with these projects and how far we've gotten with the required
protocol support; we want and we will take this a lot further over the next&amp;nbsp;development
milestones. In the end, the .NET Services fabric ought not to care much what language
the senders and listeners&amp;nbsp;are written in&amp;nbsp;and what platform&amp;nbsp;they run
on. We're building a universal services platform. We're taking&amp;nbsp;Java and Ruby
very seriously and have a few more platforms on the list for which we want&amp;nbsp;to
add explicit support. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=535b30fb-3e2c-442b-9fa2-33adb0f4acb1" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,535b30fb-3e2c-442b-9fa2-33adb0f4acb1.aspx</comments>
      <category>PDC 08</category>
      <category>Azure</category>
      <category>.NET Services</category>
    </item>
  </channel>
</rss>