<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Forward Thinking</title><link>http://blogs.msdn.com/b/piyushjo/</link><description>All things WCF...</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Error "An extension of name '&lt;x&gt;' already appears in extension collection" with .Net 4.5 RC? </title><link>http://blogs.msdn.com/b/piyushjo/archive/2012/06/19/error-quot-an-extension-of-name-lt-x-gt-already-appears-in-extension-collection-quot-with-net-4-5-rc.aspx</link><pubDate>Tue, 19 Jun 2012 05:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10321609</guid><dc:creator>PiyushJo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10321609</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2012/06/19/error-quot-an-extension-of-name-lt-x-gt-already-appears-in-extension-collection-quot-with-net-4-5-rc.aspx#comments</comments><description>&lt;p&gt;Do you happen to see any of the following&amp;nbsp;errors when you upgrade your machine to .Net 45?&lt;/p&gt;
&lt;p&gt;System.Configuration.ConfigurationErrorsException:&lt;b&gt;An extension of name '&lt;i&gt; udpTransport&lt;/i&gt; ' already appears in extension collection. Extension names must be unique.&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;System.Configuration.ConfigurationErrorsException:&lt;b&gt;An extension of name 'netHttpBinding' already appears in extension collection. Extension names must be unique.&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;In .NET 4.5, WCF has added UdpBinding (UDP) and NetHttpBinding (WebSockets) as standard bindings for the benefit of customers. If you happen to use any of .NET 4.0 WCF samples which help in implementing a custom UDP transport or netHttp transport binding element (old custom binding sample&amp;nbsp;unrelated to WebSockets) and migrate your machine to .NET 4.5 Release candidate (RC) build, you may see an error like above. We acknowledge this as an issue and this should get automatically fixed for you in RTM build. Meanwhile here are some steps to temporarily work around this issue:&lt;/p&gt;
&lt;p&gt;Step 1.&lt;br /&gt;If you have a configuration file for your WCF client/service which fails, open and search for any binding element extension that you have configured with name &amp;ldquo;udpTransport&amp;rdquo; or &amp;ldquo;netHttpBinding&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Step 2.&lt;br /&gt;Rename it to something which is not &amp;ldquo;udpTransport&amp;rdquo; or &amp;ldquo;netHttpBinding&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Step 3.&lt;br /&gt;Restart your application / service. This should fix the problem.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;BEFORE:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;lt;system.serviceModel&amp;gt;&lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;lt;extensions&amp;gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;lt;bindingElementExtensions&amp;gt;&lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name="&lt;span style="background-color: #ffff00;"&gt;&lt;b&gt;udpTransport&lt;/b&gt;&lt;/span&gt;" type="MyCustomTransport.UdpTransportElement, MyCustomTransportLibrary" /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;/bindingElementExtensions&amp;gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;bindingElementExtensions&amp;gt;&lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name="&lt;span style="background-color: #ffff00;"&gt;&lt;b&gt;netHttpBinding&lt;/b&gt;&lt;/span&gt;" type="MyCustomTransport.NetHttpTransport, MyCustomTransportLibrary "/&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;/bindingElementExtensions&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;hellip;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;lt;/system.serviceModel&amp;gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;AFTER:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;lt;system.serviceModel&amp;gt;&lt;/i&gt;&lt;i&gt;&amp;nbsp;&lt;br /&gt;&amp;lt;extensions&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;lt;bindingElementExtensions&amp;gt;&lt;/i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name="&lt;span style="background-color: #ffff00;"&gt;&lt;b&gt;myCustomUdpTransport&lt;/b&gt;&lt;/span&gt;" type="MyCustomTransport.UdpTransportElement, MyCustomTransportLibrary" /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;/bindingElementExtensions&amp;gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;lt;bindingElementExtensions&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name="&lt;span style="background-color: #ffff00;"&gt;&lt;b&gt;myCustomNetHttpBinding&lt;/b&gt;&lt;/span&gt;" type="MyCustomTransport.NetHttpTransport, MyCustomTransportLibrary" /&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;/bindingElementExtensions&amp;gt;&lt;/i&gt;&lt;i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;hellip;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;lt;/system.serviceModel&amp;gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10321609" width="1" height="1"&gt;</description></item><item><title>Windows Azure Service Bus – Push based programming approach</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/11/02/windows-azure-service-bus-push-based-programming-approach.aspx</link><pubDate>Wed, 02 Nov 2011 06:13:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10232345</guid><dc:creator>PiyushJo</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10232345</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/11/02/windows-azure-service-bus-push-based-programming-approach.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;While working with Azure Service Bus, either with the queue or with the topic/subscription, you need to explicitly write code to pull messages from the queue or from the subscription. A typical pattern looks like the following:&lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f4cc0f11-b328-4f9c-b8a9-bc7662660c8a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a SB queue&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueDescription&lt;/span&gt; queue = CreateQueue();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create a factory and client to talk to this queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt; factory = &lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt;.Create(ServiceUri, TokenProvider);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueClient&lt;/span&gt; client = factory.CreateQueueClient(queue.Path);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Send a message to the queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; requestMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.Send(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(requestMessage));&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Receive the message from the queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; responseQueueMessage = client.Receive();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; responseMessage = responseQueueMessage.GetBody&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Note how you have to write code in line 13,14 to receive the messages from the queue. Programing with topic/subscription follow similar pattern in how you need to pull messages from the subscription client. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Now what if the queue is constantly receiving messages that you need to process or if you want to use a session full communication with the queue or if you want to do custom processing of messages based on some message content or if you want to carry out an async operation when you receive the message? You may be able to program these scenarios but the number of lines and the complexity of the code increases. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;If you think about it – receiving a message and doing “something” with it is exactly what a WCF service does so wouldn’t it be cool if there is an ability to start up a WCF service which will listen for messages received by the queue/subscription and do whatever that you want to do with this message? This is essentially what I meant by the title – Push based programing approach. This means that you don’t have to worry about constantly pulling the messages from the queue – you define a service method (or methods as we will see) to do whatever you want to do when the message is received and the WCF service, like a humble servant, will do it for you. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Today we uploaded a &lt;a href="http://nuget.org/List/Packages/WindowsAzure.ServiceBus.Samples.PushProgrammingModel" target="_blank"&gt;Nuget package&lt;/a&gt; (containing source and sample) which introduce a set of extension methods on the QueueClient and SubscriptionClient which take care of starting up a WCF service instance and then we follow a convention based approach to route the queued messages to the appropriate service method which takes care of handling its processing. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;The package walks you through a set of ten scenarios – first five of which explore Service Bus as it is today and the remaining five build on the push based programming model to show how easy it has become now to program against Service Bus. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 1&lt;/strong&gt; – We enumerate all the &lt;strong&gt;queues&lt;/strong&gt; in your namesapce using NamespaceManager.GetQueues() method:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5706.image_5F00_7016E675.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5102.image_5F00_thumb_5F00_56AEE33B.png" width="385" height="82" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 2&lt;/strong&gt; -&amp;#160; We enumerate all the &lt;strong&gt;topics&lt;/strong&gt; in your namespace using NamespaceManager.GetTopics() method:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7343.image_5F00_3A31F15B.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7652.image_5F00_thumb_5F00_55D67D51.png" width="388" height="111" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 3&lt;/strong&gt; -&amp;#160; We show how you can send and receive messages to a queue using a QueueClient formed from a MessagingFactory:&lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ccc6d4c6-0da1-462d-bab8-d67baf872616" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a SB queue&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueDescription&lt;/span&gt; queue = CreateQueue();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create a factory and client to talk to this queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt; factory = &lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt;.Create(ServiceUri, TokenProvider);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueClient&lt;/span&gt; client = factory.CreateQueueClient(queue.Path);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Send a message to the queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; requestMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.Send(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(requestMessage));&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message sent to the queue - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, requestMessage);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Receive the message from the queue&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; responseQueueMessage = client.Receive();&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; responseMessage = responseQueueMessage.GetBody&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message received from the queue - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, responseMessage);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Cleanup&lt;/span&gt;&lt;/li&gt; &lt;li&gt;client.Close(); &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;factory.Close();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;This example shows how you program against Service Bus queue right now. &lt;/font&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/2061.image_5F00_75192424.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4135.image_5F00_thumb_5F00_068984FD.png" width="518" height="87" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 4&lt;/strong&gt; - We show how you can send messages to a topic and receive messages via a subscription client:&lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f98caf18-e515-4556-9f3c-84521e04f8d9" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; topicName = &lt;span style="color:#a31515"&gt;&amp;quot;news&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; subscriptionName = &lt;span style="color:#a31515"&gt;&amp;quot;mySubscription&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Delete the topic if it already exists&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (NamespaceManager.TopicExists(topicName))&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    NamespaceManager.DeleteTopic(topicName);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create the topic &lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Creating new topic - &amp;#39;{0}&amp;#39;&amp;quot;&lt;/span&gt;, topicName);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;TopicDescription&lt;/span&gt; topic = NamespaceManager.CreateTopic(topicName);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create a subscription&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Creating new subscription - &amp;#39;{0}&amp;#39;&amp;quot;&lt;/span&gt;, subscriptionName);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;SubscriptionDescription&lt;/span&gt; subs = NamespaceManager.CreateSubscription(topic.Path, subscriptionName);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create a factory to talk to the topic &amp;amp; subscription&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt; factory = &lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt;.Create(ServiceUri, TokenProvider);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a topic client to talk to this topic&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;TopicClient&lt;/span&gt; topicClient = factory.CreateTopicClient(topic.Path);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Send a message to the topic&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; requestMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message sent to the topic - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, requestMessage);&lt;/li&gt; &lt;li&gt;topicClient.Send(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(requestMessage));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a subscription client to receive messages&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;SubscriptionClient&lt;/span&gt; subscriptionClient = factory.CreateSubscriptionClient(topic.Path, subs.Name);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Receive the messages from the subscription&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; responseQueueMessage = subscriptionClient.Receive();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; responseMessage = responseQueueMessage.GetBody&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message received from the subscription - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, responseMessage);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Cleanup&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;subscriptionClient.Close();&lt;/li&gt; &lt;li&gt;topicClient.Close(); &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;factory.Close();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Again – this example shows how you program against Service Bus topic/subscription currently. &lt;/font&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1884.image_5F00_36D059B3.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/2475.image_5F00_thumb_5F00_1D685679.png" width="526" height="82" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 5&lt;/strong&gt; -&amp;#160; We show the WCF integration – how you can create a WCF service which will listen on a Service Bus endpoint and how you can relay messages using a WCF client to this WCF service via the Azure Service Bus. &lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:40f0bdc0-6f89-45c3-baa8-f0e4f893ef8f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;NetMessagingBinding&lt;/span&gt; binding = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;NetMessagingBinding&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Start up the Echo WCF service listening via Azure Service Bus&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;ServiceHost&lt;/span&gt; host = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ServiceHost&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;EchoService&lt;/span&gt;));&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;ServiceEndpoint&lt;/span&gt; echoServiceEndpoint&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    = host.AddServiceEndpoint(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;IEchoService&lt;/span&gt;), binding, QueueAddress);&lt;/li&gt; &lt;li&gt;echoServiceEndpoint.Behaviors.Add(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TransportClientEndpointBehavior&lt;/span&gt;(TokenProvider));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;host.Open();&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;WCF service up and running, listening on {0}&amp;quot;&lt;/span&gt;, QueueAddress);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a WCF channel factory and client to send message to the Azure Service Bus&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;ChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;IEchoService&lt;/span&gt;&amp;gt; factory = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;IEchoService&lt;/span&gt;&amp;gt;&lt;/li&gt; &lt;li&gt;    (binding, &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;EndpointAddress&lt;/span&gt;(QueueAddress));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;factory.Endpoint.Behaviors.Add(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TransportClientEndpointBehavior&lt;/span&gt;(TokenProvider));&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;IEchoService&lt;/span&gt; proxy = factory.CreateChannel();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Send messages to the service&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; requestMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;proxy.Echo(requestMessage);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message sent to the queue - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, requestMessage);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// clean up the client and service&lt;/span&gt;&lt;/li&gt; &lt;li&gt;factory.Close();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;host.Close();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Nothing new here - a typical output will look like the following: &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4628.image_5F00_5CC60A09.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0334.image_5F00_thumb_5F00_0327ED55.png" width="533" height="81" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 6&lt;/strong&gt; – With scenario 6 onwards we start harnessing the power of the Service Bus push based programming library.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;We start with a simple scenario applying this new approach to receive messages. &lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:451b1215-5c8c-44f9-ade0-8b7fad641cd2" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a ServiceBus queue. &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueDescription&lt;/span&gt; queue = CreateQueue();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create a factory and client to talk to this queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt; factory = &lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt;.Create(ServiceUri, TokenProvider);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueClient&lt;/span&gt; client = factory.CreateQueueClient(queue.Path);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Use the extension method to pass in a delegate &lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;//  which will handle all messages received by the queue&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.StartListener(message =&amp;gt; &lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message received from the queue - {0}&amp;quot;&lt;/span&gt;, message.GetBody&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;()));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Send a message to the queue&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; helloMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;client.Send(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(helloMessage));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message sent to the queue - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, helloMessage);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Send another message to the queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; byeMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Bye World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.Send(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(byeMessage));&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message sent to the queue - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, byeMessage);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// clean up the client and service&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.StopListener(); &lt;/li&gt; &lt;li&gt;client.Close();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;factory.Close();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Note line 10 – here we are using the StartListener extension method on QueueClient which takes in a delegate which will handle the messages received by the queue henceforth. &lt;/font&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following: &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1488.image_5F00_62A0ADA2.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8360.image_5F00_thumb_5F00_4938AA68.png" width="539" height="111" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 7&lt;/strong&gt; – We expand on the previous scenario by explicitly providing a service type which will be responsible for handling the incoming messages to the queue. We also make the scenario interesting by attaching an Action property to each BrokeredMessage we are sending to the queue. The idea is to route messages to different service methods based on this Action property of the incoming message. &lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bb292426-92b5-4e1b-865e-1b79c857d64d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MyActionOrientedEchoService&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    [&lt;span style="color:#2b91af"&gt;OnMessage&lt;/span&gt;(Action = &lt;span style="color:#a31515"&gt;&amp;quot;EchoOnce&amp;quot;&lt;/span&gt;)]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; EchoOnce(&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; msg)&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message received by EchoOnce method&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; messageBody = msg.GetBody&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(messageBody);&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    [&lt;span style="color:#2b91af"&gt;OnMessage&lt;/span&gt;(Action = &lt;span style="color:#a31515"&gt;&amp;quot;EchoTwice&amp;quot;&lt;/span&gt;)]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; EchoTwice(&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; msg)&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message received by EchoTwice method&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; messageBody = msg.GetBody&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(messageBody);&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(messageBody);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    }&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2d4575d8-bfca-435c-b1ef-2fe567059be8" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a ServiceBus queue. &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueDescription&lt;/span&gt; queue = CreateQueue();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create a factory and client to talk to this queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt; factory = &lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt;.Create(ServiceUri, TokenProvider);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueClient&lt;/span&gt; client = factory.CreateQueueClient(queue.Path);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Use the extension method to start the WCF service &lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;//  which will handle the queued messages based on its Action property&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.StartListener(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;MyActionOrientedEchoService&lt;/span&gt;));&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; requestMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Send message to the queue - to the EchoOnce operation&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; message = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(requestMessage);&lt;/li&gt; &lt;li&gt;message.SetAction(&lt;span style="color:#a31515"&gt;&amp;quot;EchoOnce&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message &amp;#39;{0}&amp;#39; sent with &amp;#39;{1}&amp;#39; action&amp;quot;&lt;/span&gt;, requestMessage, &lt;span style="color:#a31515"&gt;&amp;quot;EchoOnce&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;client.Send(message);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Send message to the queue - to the EchoTwice operation&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; anotherMessage = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(requestMessage);&lt;/li&gt; &lt;li&gt;anotherMessage.SetAction(&lt;span style="color:#a31515"&gt;&amp;quot;EchoTwice&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message &amp;#39;{0}&amp;#39; sent with &amp;#39;{1}&amp;#39; action&amp;quot;&lt;/span&gt;, requestMessage, &lt;span style="color:#a31515"&gt;&amp;quot;EchoTwice&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;client.Send(anotherMessage);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Cleanup&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.StopListener(); &lt;/li&gt; &lt;li&gt;client.Close();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;factory.Close();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;In line 10 – we are again using the StartListener extension method to start up the service of type ‘MyActionOrientedEchoService’. Note the following points about the service:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2" face="Verdana"&gt;the service doesn’t need to implement any interface or be marked with a ServiceContract attribute&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Verdana"&gt;the service has two methods marked with the OnMessage attribute. This is a new attribute defined in the sample. All queued messages will be directed to a method decorated with this attribute. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Verdana"&gt;The regular convention though, which is automatically understood, is to use a public method named OnReceivedMessage returning void and accepting a single parameter of type BrokeredMessage which will be used to dispatch the incoming messages. In the absence of such a method, the dispatching is done to a public method with return type void and which accepts a parameter of type BrokeredMessage only if there is exactly one such method. Of course – OnMessage attribute is used to override such conventions. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Verdana"&gt;In this scenario – we want to do custom processing based on received messages and hence we define two service methods each with OnMessage attribute and using the Action parameter which will help in directing the message to the correct operation. &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;In line 15 and 21, we are using the SetAction extension method to add an ‘action’ property to the BrokeredMessage and this will be used to direct the message to the suitable service method. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7380.image_5F00_12E78259.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5621.image_5F00_thumb_5F00_0E710192.png" width="549" height="122" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 8&lt;/strong&gt; – We integrate sessions in this scenario. We see how we can easily spawn up different service instances which will handle the incoming queued messages based on the SessionId we attach to the brokered message. &lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:aed26611-6581-44cb-b3b9-93de63e2238d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MySessionfulService&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; OnReceiveMessage(&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; msg)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Received Message - {0}, Received by service - {1}&amp;quot;&lt;/span&gt;,&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            msg.GetBody&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;(), &lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.GetHashCode());&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; OnError(&lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Error occurred&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(e.Message);&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09a31e36-eff1-4f64-b61b-8abfdd1242c0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a sessionful queue&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueDescription&lt;/span&gt; queue = NamespaceManager.CreateQueue&lt;/li&gt; &lt;li&gt;    (&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;QueueDescription&lt;/span&gt;(QueueName) { RequiresSession = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt; });&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a factory and client to talk to this queue&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt; factory = &lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt;.Create(ServiceUri, TokenProvider);&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;QueueClient&lt;/span&gt; client = factory.CreateQueueClient(queue.Path);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Use the extension method to start up the WCF service &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// which will process the sessionful queued messages received by the queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;client.StartListener(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;MySessionfulService&lt;/span&gt;), requiresSession: &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; helloMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; byeMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Bye World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Start sending messages to the queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Session 1&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; message1 = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(helloMessage);&lt;/li&gt; &lt;li&gt;message1.SessionId = &lt;span style="color:#a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.Send(message1);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; message2 = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(byeMessage);&lt;/li&gt; &lt;li&gt;message2.SessionId = &lt;span style="color:#a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.Send(message2);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Session 2&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; message3 = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(helloMessage);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;message3.SessionId = &lt;span style="color:#a31515"&gt;&amp;quot;2&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;client.Send(message3);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; message4 = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(byeMessage);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;message4.SessionId = &lt;span style="color:#a31515"&gt;&amp;quot;2&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;client.Send(message4);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Cleanup&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.Close();&lt;/li&gt; &lt;li&gt;factory.Close();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;In line 2, we are ensuring that the ServiceBus queue enables sessions and correspondingly in line 11, we are starting up the WCF service listener enabling sessions. &lt;/font&gt;&lt;font size="2" face="Verdana"&gt;Note that in the MySessionfulService implementation we are sticking to the convention of using the method with the signature – void OnReceivedMessage (BrokeredMessage msg) which will handle all incoming messages. Also note another convention based method void OnError(Exception ex) – this is used to handle all the errors arising out of handling the queued messages. Again – for handling errors&amp;#160; - we will look for a method which conforms to this signature if an OnError method does not exist. Internally, we are simply registering an IErrorHandler that redirects Exceptions to the error handler. This means that anything that is bubbled up to the IErrorHandler by ServiceModel will make its way to the error handler&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1004.image_5F00_4D62822D.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7776.image_5F00_thumb_5F00_3F24093D.png" width="554" height="64" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Note that I can also add a service behavior specifying the InstanceContextMode of my WCF service if I so desire – by default it is PerSession but I can change it to PerCall or Single to influence how my service method processes the incoming messages.&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 9&lt;/strong&gt; – We extend the example to show how you can use the same WCF based push approach to receive messages for a subscription from a topic. &lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3c780ad5-1e92-4097-bf44-56890c5c8424" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create the topic &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Creating new topic - &amp;#39;{0}&amp;#39;&amp;quot;&lt;/span&gt;, topicName);&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;TopicDescription&lt;/span&gt; topic = NamespaceManager.CreateTopic(topicName);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a subscription&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Creating new subscription - &amp;#39;{0}&amp;#39;&amp;quot;&lt;/span&gt;, subscriptionName);&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;SubscriptionDescription&lt;/span&gt; subs = NamespaceManager.CreateSubscription(topic.Path, subscriptionName);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a factory to talk to the topic &amp;amp; subscription&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt; factory = &lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt;.Create(ServiceUri, TokenProvider);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create a topic client to talk to this topic&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;TopicClient&lt;/span&gt; topicClient = factory.CreateTopicClient(topic.Path);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a subscription client to retrive messages&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;SubscriptionClient&lt;/span&gt; subscriptionClient = factory.CreateSubscriptionClient(topic.Path, subs.Name);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Start the WCF service which will receive the messages sent to the topic&lt;/span&gt;&lt;/li&gt; &lt;li&gt;subscriptionClient.StartListener(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;MyQueuedMessageHandlerService&lt;/span&gt;)); &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Send a message to the topic&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; requestMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message sent to the topic - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, requestMessage);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;topicClient.Send(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(requestMessage));&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Cleanup&lt;/span&gt;&lt;/li&gt; &lt;li&gt;subscriptionClient.StopListener(); &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;subscriptionClient.Close();&lt;/li&gt; &lt;li&gt;topicClient.Close();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;factory.Close();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;All the overloads which exist on the QueueClient, as we saw above, are also available on the SubscriptionClient. A WCF service will be started up in a similar way to handle all messages received by this subscription. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/6138.image_5F00_177D8D13.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7624.image_5F00_thumb_5F00_442646EC.png" width="553" height="98" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Scenario 10&lt;/strong&gt; – We show how you can use the same approach to carry out an async operation at the receipt of the queued message.&lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c068ff40-526a-40b8-9399-467b1edb2c48" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MyAsyncEchoService&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Task&lt;/span&gt; DoComplexTaskAsync(&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; message)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Async method called&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Task&lt;/span&gt;.Factory.StartNew(() =&amp;gt; &lt;/li&gt; &lt;li&gt;        { &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;// Do some complex task&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Starting complex task at {0}&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt;.Now.ToString());  &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#2b91af"&gt;Thread&lt;/span&gt;.Sleep(5000);&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Completing complex task at {0}&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt;.Now.ToString());  &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        });&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3ecd88a0-27df-4410-b3bd-4273d135601d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Create a ServiceBus queue. &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueDescription&lt;/span&gt; queue = CreateQueue();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Create a factory and client to talk to this queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt; factory = &lt;span style="color:#2b91af"&gt;MessagingFactory&lt;/span&gt;.Create(ServiceUri, TokenProvider);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;QueueClient&lt;/span&gt; client = factory.CreateQueueClient(queue.Path);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Use the extension method to start the WCF service &lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;//  which will handle the queued messages based on its Action property&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.StartListener(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;MyAsyncEchoService&lt;/span&gt;));&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Send message to the queue&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; requestMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt; message = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BrokeredMessage&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;client.Send(message);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Message sent to the queue - &amp;#39;{0}&amp;#39; &amp;quot;&lt;/span&gt;, requestMessage);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#008000"&gt;// Cleanup&lt;/span&gt;&lt;/li&gt; &lt;li&gt;client.StopListener(); &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;client.Close();&lt;/li&gt; &lt;li&gt;factory.Close();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;The service implementation is the only interesting part otherwise the sample is identical to what we have seen in earlier scenarios. Note how the method takes in a BrokeredMessage and returns a Task. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;A typical output will look like the following:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7128.image_5F00_4C5A6C83.png"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7217.image_5F00_thumb_5F00_6073890C.png" width="555" height="93" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Thank you!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Special thanks to &lt;/strong&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/youssefm/" target="_blank"&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Youssef&lt;/strong&gt;&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt; who was instrumental in developing this library.&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10232345" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Service+Bus/">Service Bus</category></item><item><title>Calling a WCF service from a Metro application – service deployed in Azure</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/11/01/calling-a-wcf-service-from-a-metro-application-service-deployed-in-azure.aspx</link><pubDate>Tue, 01 Nov 2011 00:24:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10231890</guid><dc:creator>PiyushJo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10231890</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/11/01/calling-a-wcf-service-from-a-metro-application-service-deployed-in-azure.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2" face="Calibri"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Alright then – lets move the WCF service to the cloud! &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;&lt;strong&gt;Scenario&lt;/strong&gt; – This is another take on my “Sunny or Cloudy” metro application we developed in my &lt;/font&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/piyushjo/archive/2011/09/22/wcf-in-win8-metro-styled-apps-absolutely-supported.aspx"&gt;&lt;font size="2" face="Verdana"&gt;first post&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;. We will make it visually appealing! And how do I plan to do that? Have you noticed how in the TV forecast, they show you weather information overlapped on a map of the area – something like the following:&lt;/font&gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1731.image_5F00_6B7F8F2A.png"&gt;&lt;font size="2"&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3377.image_5F00_thumb_5F00_2A04DCD1.png" width="244" height="212" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Well, we will use the same concept and deploy a WCF service in Azure which given a zip code, will give us an area map and the weather information about it. Following is the screenshot from our finished metro client application:&lt;/font&gt;&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/6114.image_5F00_34560131.png"&gt;&lt;font size="2"&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7510.image_5F00_thumb_5F00_734781CC.png" width="244" height="216" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;I passed the zip code of Manhattan area of New York city and got back the area’s Bing maps link and the weather information which I am showing overlapped on the map. (It surely has cleared up there after snowing over the weekend – a surprise snow storm early in October itself!)&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;WCF service :&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;The WCF service, which we will be deploying in Azure, will act as an aggregator of information will be developed in .net 4.0 so that we can deploy it in Azure. Following diagram shows its architecture:&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4530.image_5F00_474F1163.png"&gt;&lt;font size="2"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4530.image_5F00_474F1163.png"&gt;&lt;font size="2"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4530.image_5F00_474F1163.png"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4530.image_5F00_474F1163.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0724.image_5F00_thumb_5F00_258338D2.png" width="510" height="152" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/a&gt;&lt;/a&gt;&lt;/font&gt;&lt;/a&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2" face="Verdana"&gt;Metro client application users will enter a zip code. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Verdana"&gt;This zip code will be sent to the WCF service deployed in Azure. The service will be deployed in a web role with BasicHttpBinding and hence accessible over http and we will configure it with TransportWithMessageCredential security mode so that we can use username/password credentials to authenticate the metro client. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Verdana"&gt;This WCF service will use &lt;/font&gt;&lt;a href="http://nuget.org/List/Packages/HttpClient" target="_blank"&gt;&lt;font size="2" face="Verdana"&gt;HttpClient library&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt; (This is a NuGet package for the HtpClient functionality for .Net 4.0, HttpClient is only available in .Net 4.5) to make calls to the Bing Maps REST APIs to fetch a link to the map of the area. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Verdana"&gt;The Azure WCF service will also call out to an &lt;/font&gt;&lt;a href="http://wsf.cdyne.com/WeatherWS/Weather.asmx" target="_blank"&gt;&lt;font size="2" face="Verdana"&gt;external ASMX weather service&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt; to get the weather details. Notably – this weather webservice returns back an image url describing the weather conditions which we will use to overlay on the area map.&amp;#160; This is the ‘sunny’ weather image link in the metro client screenshot above on top of the Manhattan area map. &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2" face="Verdana"&gt;1. So we start with an Azure Cloud application project and add a WCF Service WebRole. You need to download the “Windows Azure Tools for Microsoft Visual Studio” for this. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8737.image_5F00_7076A9A1.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0317.image_5F00_thumb_5F00_1744BFE2.png" width="244" height="148" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5826.image_5F00_7729B324.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4848.image_5F00_thumb_5F00_1DF7C965.png" width="244" height="154" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;2. Next, we define the service and the data contract for the Azure WCF service:&lt;/font&gt; &lt;/font&gt;&lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a704b860-520a-41b7-9851-5c6dd0473558" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;[&lt;span style="color:#2b91af"&gt;ServiceContract&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IWeatherInfo&lt;/span&gt;&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    [&lt;span style="color:#2b91af"&gt;OperationContract&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;WeatherInfo&lt;/span&gt; GetWeatherInfo(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; inputZip);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;[&lt;span style="color:#2b91af"&gt;DataContract&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;WeatherInfo&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    [&lt;span style="color:#2b91af"&gt;DataMember&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Locality { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;    &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    [&lt;span style="color:#2b91af"&gt;DataMember&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; WeatherDescription { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;/li&gt; &lt;li&gt;    [&lt;span style="color:#2b91af"&gt;DataMember&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; WeatherImageUri { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;    &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    [&lt;span style="color:#2b91af"&gt;DataMember&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; MapImageUri { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;The service contract is straightforward – it takes a zip code and returns a data contract consisting of the members we will use in the metro client to display the area and weather information. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;3) To make calls to the Bing Maps REST APIs – I have chosen to use the HttpClient so we need to download the HttpClient NuGet reference.&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7585.image6_5F00_68EB3A34.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8156.image6_5F00_thumb_5F00_0FB95075.png" width="208" height="153" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3441.image19_5F00_1D8B9670.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8640.image19_5F00_thumb_5F00_4459ACB0.png" width="252" height="152" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2" face="Verdana"&gt;4) And to make calls to the external weather web service – &lt;/font&gt;&lt;a href="http://wsf.cdyne.com/WeatherWS/Weather.asmx"&gt;&lt;font size="2" face="Verdana"&gt;http://wsf.cdyne.com/WeatherWS/Weather.asmx&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;, we need to add a service reference to it.&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0310.image_5F00_243E9FF3.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1881.image_5F00_thumb_5F00_1D1F637B.png" width="244" height="192" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;5) I’ll let you explore the implementation of the WCF service by downloading the sample code from below. Few highlights of the code though - &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;a) The code below shows how we are creating a WCF client proxy to talk to the weather ASMX webservice and making a call to it using the zip code passed to the service method call:&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:71680aca-564d-4ddf-99ec-16070b62b741" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;WeatherInfo&lt;/span&gt; returnResults = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;WeatherInfo&lt;/span&gt;(); &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;WeatherWebservice.&lt;span style="color:#2b91af"&gt;WeatherSoapClient&lt;/span&gt; weatherProxy = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; WeatherWebservice.&lt;span style="color:#2b91af"&gt;WeatherSoapClient&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;WeatherSoap&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;WeatherWebservice.&lt;span style="color:#2b91af"&gt;WeatherReturn&lt;/span&gt; weatherResults = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; WeatherWebservice.&lt;span style="color:#2b91af"&gt;WeatherReturn&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Call the weather web service to get weather information &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;weatherResults = weatherProxy.GetCityWeatherByZIP(inputZip);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2" face="Verdana"&gt;b) The code below shows how we are using the HttpClient API to make a call to the Bing Maps REST API. You will need to register with the Bing Maps (&lt;/font&gt;&lt;a title="http://www.bingmapsportal.com/" href="http://www.bingmapsportal.com/"&gt;&lt;font size="2" face="Verdana"&gt;http://www.bingmapsportal.com/&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt;) to get a developer key to use the maps APIs. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;To get the area map url - I needed to make a couple of these REST calls – one to get the latitude/longitude of the area given a zip code and the next to get the a maps image url feeding it the latitude/longitude I retrieved from the first call.&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1678c8ce-7a99-4e29-ae24-e60891aff349" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Use the Web APIs HttpClient to access Bing Maps REST service to get the city map &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; bingMapsKey = &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;enter your bing maps key&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;HttpClient&lt;/span&gt; client = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HttpClient&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; bingMapsPointDataQuery = &lt;span style="color:#2b91af"&gt;String&lt;/span&gt;.Format&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    (&lt;span style="color:#a31515"&gt;&amp;quot;http://dev.virtualearth.net/REST/v1/Locations?countryRegion=US&amp;amp;postalCode={0}&amp;amp;o=xml&amp;amp;key={1}&amp;quot;&lt;/span&gt;, &lt;/li&gt; &lt;li&gt;        inputZip, bingMapsKey);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#2b91af"&gt;HttpResponseMessage&lt;/span&gt; bingMapsPointsData = client.Get(bingMapsPointDataQuery);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;6. Lets configure security on our Azure WCF service:&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;a. Open up the WCF service web.config and add an https protocol mapping -&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a2702b7b-b57c-4df1-ab35-48dce6136ffe" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Web.config Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;protocolMapping&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;remove&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;scheme&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;http&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;basicHttpBinding&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;secureBinding&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;scheme&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;https&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;protocolMapping&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;font face="Calibri"&gt;&lt;/font&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Verdana"&gt;We are removing the http access of the WCF service and restricting it to https. &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Verdana"&gt;b. Next configure the binding to use TransportWithMessageCredential security mode and UserName client credential type. This will allow us to pass a username/password from the metro client to authenticate. &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a9591369-ec66-4812-b39e-d639db1f1df0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Web.config Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;secureBinding&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;security&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;mode&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;TransportWithMessageCredential&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;message&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;clientCredentialType&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;UserName&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;security&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;basicHttpBinding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:65dcedbe-b1fb-420b-9341-ecfaf8d31106" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;behaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;behavior&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceMetadata&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;httpsGetEnabled&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;true&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Verdana"&gt;We are also configuring http&lt;font style="background-color: #ffff00"&gt;&lt;strong&gt;s&lt;/strong&gt;&lt;/font&gt;GetEnabled on the serviceMetadata behavior to allow us to expose the service metadata over https exclusively. &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Verdana"&gt;c. Next, we will add a custom userNamePasswordValidator so that we can validate the credentials passed by the Metro client. &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d23f6e1b-6188-4d44-8cd5-d91f69a748ea" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MyCustomUserNamePasswordValidator&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;UserNamePasswordValidator&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Validate(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; userName, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; password)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (userName != &lt;span style="color:#a31515"&gt;&amp;quot;myAzureUsername&amp;quot;&lt;/span&gt; || password != &lt;span style="color:#a31515"&gt;&amp;quot;myAzurePassword&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;FaultException&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;Invalid credentials&amp;quot;&lt;/span&gt;); &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        }&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Verdana"&gt;This is just a hard coded credentials check for demo purpose! Next we need to wire this custom username/password validator to the service by adding a serviceCredentials service behavior. &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6fccb9e4-0eb4-41c7-b093-194bf257f850" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Web.config Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000"&gt; Adding custom username password validator &lt;/span&gt;&lt;span style="color:#0000ff"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceCredentials&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;userNameAuthentication&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;userNamePasswordValidationMode&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;Custom&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                              &lt;span style="color:#0000ff"&gt;&lt;/span&gt;&lt;span style="color:#ff0000"&gt;customUserNamePasswordValidatorType&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;WCFServiceWebRole.MyCustomUserNamePasswordValidator, WCFServiceWebRole&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceCredentials&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;behavior&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;7. Now the fun part – configuring certificates which can be used by our Azure WCF service for the configured transport security. We will use self-signed certificates for this purpose. &lt;/font&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/cc949067.aspx" href="http://msdn.microsoft.com/en-us/library/cc949067.aspx"&gt;&lt;font size="2" face="Verdana"&gt;http://msdn.microsoft.com/en-us/library/cc949067.aspx&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt; is an excellent link which walks you through this – showing how to create a root certificate authority certificate (Step 1) which you will then need to install in the Trusted Root Certificate Authority of the Win8 machine (Step 2) from where the Metro client makes its call and finally creating the service certificate from the root certificate (Step 3). This service certificate will be used for SSL communication between the client and the server. Step 4 in the above walkthrough is not needed as it is IIS specific. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Make sure that you are substituting the &amp;lt;machineName&amp;gt; with the name where you will be deploying your WCF service in Azure (e.g. in my case it was piyushjoWeatherService.cloudapp.net) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4527.image_5F00_6812D44A.png"&gt;&lt;font size="2"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4527.image_5F00_6812D44A.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4540.image_5F00_thumb_5F00_23D26CFE.png" width="271" height="289" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;This is required because this certificate is going to be used by our WCF service deployed in Azure at this host name and therefore when the Metro client will attempt to establish an SSL connection with this service, WCF client will ensure that the subject name of the certificate with which the WCF service it is talking to is configured matched exactly with the hostname it is using to make the service call. This is identical to how you configure if your service was hosted on premise – where you need to make sure that the certificate is issued to a subject name matching the machine name where the service is hosted. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;For actual production deployment you would go to a certificate authority like VeriSign to provide you a certificate with the subject name where you will be deploying your service so no need to create these self-signed certificates. You will also not need the Step 2 from above link to deploy the root certificate in the Trusted Root authority store because trusted root certificates from reputed authorities like VeriSign are already installed there.&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;8. Finally we add the certificate to the WCF web role and configure the Azure WCF service web role to expose an https endpoint and use the certificate we just created to provide SSL security for this https endpoint. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1616.image29_5F00_1CB33086.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3343.image29_5F00_thumb_5F00_1593F40E.png" width="533" height="180" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3365.image32_5F00_3C620A4E.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7651.image32_5F00_thumb_5F00_07557B1E.png" width="538" height="162" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;9. Lastly we create a package for the Azure WCF service and deploy it to an Azure production deployment along with the certificate. The final deployment will look like this (depending on the instances you have requested) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;[Note that you can consider using the MSDN subscriber benefits for deploying in Azure if you are an MSDN member - &lt;/font&gt;&lt;a href="http://www.microsoft.com/windowsazure/msdn-benefits/"&gt;&lt;font size="2" face="Verdana"&gt;http://www.microsoft.com/windowsazure/msdn-benefits/&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt;]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/6507.image_5F00_39C471D5.png"&gt;&lt;font size="2"&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/6505.image_5F00_thumb_5F00_128A28A0.png" width="539" height="153" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;WCF client :&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;So once you have deployed your WCF service in Azure, &lt;/font&gt;&lt;font face="Verdana"&gt;you need to create the Metro client to connect to this service. You will use the Add Service Reference (ASR) functionality for this. There is no difference from what I have showed in my previous &lt;/font&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/piyushjo/archive/2011/09/22/wcf-in-win8-metro-styled-apps-absolutely-supported.aspx"&gt;&lt;font size="2" face="Verdana"&gt;post&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt; – you just pass the reference to your deployed Azure WCF service while generating the service reference – e.g. I used the reference - &lt;/font&gt;&lt;a href="https://piyushjoweatherservice.cloudapp.net/WeatherService.svc"&gt;&lt;font size="2" face="Verdana"&gt;https://piyushjoweatherservice.cloudapp.net/WeatherService.svc&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt; to my Azure deployed service.&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;[Note that this service is no longer running in Azure &lt;img alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8171.wlEmoticon_2D00_smile_5F00_6ED10105.png" /&gt; so you will have to point the sample code to your own deployment] &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Interesting parts of the generated service reference are the GetEndpointAddress method which references the Azure WCF service:&lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:eddcb490-9b96-4ddb-9267-5396ee096ee3" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration) {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IWeatherInfo)) {&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; System.ServiceModel.EndpointAddress(&lt;span style="color:#a31515"&gt;&amp;quot;https://piyushjoweatherservice.cloudapp.net/WeatherService.svc&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            }&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; System.&lt;span style="color:#2b91af"&gt;InvalidOperationException&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;&amp;quot;Could not find endpoint with name &amp;#92;&amp;#39;{0}&amp;#92;&amp;#39;.&amp;quot;&lt;/span&gt;, endpointConfiguration));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;and the GetBindingForEndpoint method which is configuring the TransportWithMessageCredential security mode on the binding&lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:38fabec5-2e18-41d9-8d7c-4365924653b5" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration) {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IWeatherInfo)) {&lt;/li&gt; &lt;li&gt;                System.ServiceModel.BasicHttpBinding result = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; System.ServiceModel.BasicHttpBinding();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                result.AllowCookies = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;                result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportWithMessageCredential;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; result;&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; System.&lt;span style="color:#2b91af"&gt;InvalidOperationException&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;&amp;quot;Could not find endpoint with name &amp;#92;&amp;#39;{0}&amp;#92;&amp;#39;.&amp;quot;&lt;/span&gt;, endpointConfiguration));&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Note that you don’t have to change anything in the generated service reference. ASR functionality will generate the correct service reference for you. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;And that’s it – you are ready to consume your WCF service. The metro client code looks like the following:&lt;/font&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:43208366-cd08-4cfc-b152-2972b885c18d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; async &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Button_Click(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    AzureWeatherSvcRef.WeatherInfoClient proxy&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; AzureWeatherSvcRef.WeatherInfoClient();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    proxy.ClientCredentials.UserName.UserName = &lt;span style="color:#a31515"&gt;&amp;quot;myAzureUsername&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;    proxy.ClientCredentials.UserName.Password = &lt;span style="color:#a31515"&gt;&amp;quot;myAzurePassword&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    AzureWeatherSvcRef.WeatherInfo info = await proxy.GetWeatherInfoAsync(inputZip.Text);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    WeatherReasults.Text = &lt;span style="color:#2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;&amp;quot;{0} - {1}&amp;quot;&lt;/span&gt;, info.Locality, info.WeatherDescription);&lt;/li&gt; &lt;li&gt;    MapImage.Source = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; BitmapImage(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; Uri(info.MapImageUri));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    WeatherImage.Source = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; BitmapImage(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; Uri(info.WeatherImageUri)); &lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Here I am creating a proxy to my WCF service in line 3, attaching the credentials recognized by my Azure deployed WCF service in line 6 and calling the service in line 9. As you would have gathered – considering this is a metro client application, we absolutely do not want to block the UI thread while making this call – and so we are calling the service asynchronously (note the async keyword on the button click event handler and the await keyword while making the call). Once the service returns results and populates the WeatherInfo object, I am using it to assign values to my various UI elements.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;And that was that! Let me know if any part of this walkthrough needs any further clarification and I’ll add to that. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Thanks. &lt;/font&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:2495042b-7ab0-4d60-9a35-a31a8d8d37d3" class="wlWriterEditableSmartContent"&gt;&lt;p&gt; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7103.AzureWeatherSvcClient_5F00_0FE3BC4B.zip" target="_blank"&gt;Azure Wcf Service&lt;/a&gt;&lt;br /&gt; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8662.WcfAzureService_5F00_01A5435B.zip" target="_blank"&gt;Metro Client&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10231890" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Metro/">Metro</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Windows+8/">Windows 8</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Security/">Security</category></item><item><title>Calling a WCF service from a Metro application – cross machine scenario</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/10/22/calling-a-wcf-service-from-a-metro-application-cross-machine-scenario.aspx</link><pubDate>Sat, 22 Oct 2011 06:58:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10228837</guid><dc:creator>PiyushJo</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10228837</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/10/22/calling-a-wcf-service-from-a-metro-application-cross-machine-scenario.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2" face="Verdana"&gt;So you have developed your WCF service to be consumed by your Metro client application – you would likely have done the development on your local machine. What is the next step [before we move to Azure &lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3060.wlEmoticon_2D00_smile_5F00_548B74BA.png" /&gt;] ? You will probably take your service and deploy it on another machine either for testing cross machine scenario or you are just going with on-premise hosting. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;So what is interesting here? Well, start up the metro client and try to connect to the WCF service. Does it work?&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;If you are calling the service asynchronously which is how you should be doing it – you will see the metro client just hang waiting for the service to respond. While calling synchronously you will see an Aggregate exception throw almost instantly with the inner exception being – &lt;em&gt;&lt;strong&gt;“There was no endpoint listening at &lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;a href="http://&amp;lt;serverName&amp;gt;/&amp;lt;service&amp;gt;.svc"&gt;&lt;font size="2" face="Verdana"&gt;&lt;em&gt;&lt;strong&gt;/.svc&amp;quot;&amp;gt;/.svc&amp;quot;&amp;gt;http://&amp;lt;serverName&amp;gt;/&amp;lt;service&amp;gt;.svc&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Verdana"&gt;&lt;em&gt;&lt;strong&gt; that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.&amp;quot;&lt;/strong&gt;&lt;/em&gt;.&amp;#160; with innermost exception of – &lt;em&gt;&lt;strong&gt;“{&amp;quot;An attempt was made to access a socket in a way forbidden by its access permissions XXX.XXX.XXX.XXX:80&amp;quot;}”&lt;/strong&gt;&lt;/em&gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;To fix this - what you need to do is to add an additional capability to your metro application – “Home/Work networking” – this enables metro applications access services in your domain network. More information &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464936(v=VS.85).aspx#home_and_work_networks?lcid=1033" target="_blank"&gt;here&lt;/a&gt;. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/2772.image_5F00_6910C438.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8640.image_5F00_thumb_5F00_5AD24B48.png" width="582" height="293" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Hope it helps!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Thanks.&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10228837" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Metro/">Metro</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Windows+8/">Windows 8</category></item><item><title>What’s new in WCF 4.5 – Tooltips &amp; IntelliSense</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/10/21/what-s-new-in-wcf-4-5-tooltips-amp-intellisense.aspx</link><pubDate>Fri, 21 Oct 2011 01:43:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10228432</guid><dc:creator>PiyushJo</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10228432</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/10/21/what-s-new-in-wcf-4-5-tooltips-amp-intellisense.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;So continuing on my WCF 4.5 posts - and expanding on the configuration simplicity theme - I'll dedicate this one to the simplification efforts we have done to ease configuring WCF services. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;Tooltips support and extended IntelliSense &lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Many folks have a tough time while dealing with the numerous knobs we have in the WCF configuration system. All these different configuration settings while providing immense flexibility, also add to the complexity - developers need to know each knob and also remember which knob is for what purpose. So we thought what can we do to help the developers here - we looked around and saw editors like the C# editor in Visual Studio providing nice little features of Tooltips and IntelliSense which boost developer productivity substantially and we decided to adopt them for WCF Xml configuration as well! &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;&lt;strong&gt;Tooltips support&lt;/strong&gt; is now available for WCF configuration elements and its properties in the Xml configuration editor:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/2134.image_5F00_5911A1DF.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1376.image_5F00_thumb_5F00_5E801283.png" width="509" height="88" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;The tooltip message is the same as what shows up in the description of the configuration element in the WCF configuration schema documentation in MSDN. I will admit that some of the MSDN descriptions do lack in clarity and seem ambiguous &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8233.wlEmoticon_2D00_smile_5F00_5760D60B.png" /&gt; but we are always improving the documentation on MSDN. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;There is some existing &lt;strong&gt;IntelliSense support&lt;/strong&gt; for WCF configuration already however in Visual Studio 2011, we have extended this further to cover some of the scenarios where we think this will be super useful. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Lets walk through how you configure when you have created a service and operation contract and written your WCF service implementing them. &lt;/font&gt;&lt;font face="Verdana"&gt;You open up the .config file and if you are the brave one &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8233.wlEmoticon_2D00_smile_5F00_5760D60B.png" /&gt;&amp;#160; – you start editing it by hand!&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Starting with the service tag – we now auto populate the available services:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3527.image_5F00_65331C06.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3531.image_5F00_thumb_5F00_30268CD6.png" width="519" height="165" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;OK – that’s done – then you start adding configuring the service:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;a. starting with the binding - &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4111.image_5F00_56F4A316.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3124.image_5F00_thumb_5F00_64C6E911.png" width="357" height="195" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;b. or the contract&lt;/font&gt;&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0474.image_5F00_2FBA59E1.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0407.image_5F00_thumb_5F00_6F844066.png" width="492" height="112" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;c. Or any named service or endpoint behavior which you already created: &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1067.image_5F00_686503EE.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8311.image_5F00_thumb_5F00_763749E9.png" width="494" height="155" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/6266.image_5F00_6F180D71.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1452.image_5F00_thumb_5F00_7CEA536C.png" width="497" height="183" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;As you saw – we now auto populate all of it for you to just click and select – no more copying/pasting or typing it by hand. This will eliminate all those crazy spelling mistakes where you thought you named it EndpointBehav&lt;strong&gt;ior&lt;/strong&gt; but it was actually EndpointBehav&lt;strong&gt;iour &lt;/strong&gt;and you were pulling out your hairs about why the service was behaving in unexplained manner! &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Not only this – even if you decide to ignore the IntelliSense and make mistakes – you will see validation instantly lighting up and preventing you from doing this:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7750.image_5F00_75CB16F4.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8321.image_5F00_thumb_5F00_039D5CF0.png" width="498" height="68" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;And if you don’t listen to it – it will also show up in the Warnings on the debug window:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0882.image_5F00_4E90CDBF.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1462.image_5F00_thumb_5F00_2E75C102.png" width="559" height="115" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;&lt;strong&gt;Note on the internal working -&lt;/strong&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;When a user opens up the XML editor to modify the WCF service configuration file, it reads the dotNetConfig.xsd document, which ships with Visual Studio (located here - &amp;quot; &lt;/font&gt;&lt;a href="file:///\\Program"&gt;&lt;font size="2" face="Verdana"&gt;\\Program&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt; Files (x86)\Microsoft Visual Studio 11.0\Xml\Schemas\DotNetConfig.xsd) and this file contains the .NET framework configuration schema. The XML editor uses this schema to perform validation (adding those red/blue squiggles) and provide tooltips. &lt;/font&gt;&lt;font face="Verdana"&gt;The tooltips information is extracted from the xs:annotation\xs:documentation tag:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0474.image_5F00_2756848A.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3122.image_5F00_thumb_5F00_63161D3D.png" width="620" height="156" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Since this schema definition file is picked for all application templates in Visual Studio when you are modifying the xml configuration file – this means that you will get the added IntelliSense and Tooltips support whenever you are dabbling in configuration under system.serviceModel section in Visual Studio 2011, be it WCF service application template or some console application while creating self-hosted service.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;Thank you!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10228432" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF+4-5/">WCF 4.5</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Configuration/">Configuration</category></item><item><title>WCF in Metro apps – supported functionality</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/10/19/wcf-for-metro-apps-supported-functionality.aspx</link><pubDate>Wed, 19 Oct 2011 05:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10227342</guid><dc:creator>PiyushJo</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10227342</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/10/19/wcf-for-metro-apps-supported-functionality.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;I wanted to do this quick post to outline the supported functionality in terms of commonly used APIs for WCF in Metro apps. I am not listing each and every included API in this post but just listing the top level ones which are commonly used to give you an idea. Let us know if you think there is something obvious which is missing and which you would eventually want to see in the final release. You can also drill down into the included APIs by using your favorite disassembler (for me it is Reflector!) on the reference assemblies here - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Bindings - &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;BasicHttpBinding&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;NetTcpBinding&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;NetHttpBinding&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt; CustomBinding &lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;strong&gt;Binding elements -&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;BinaryMessageEncodingBindingElement&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;TextMessageEncodingBindingElement &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;ConnectionOrientedTransportBindingElement&amp;nbsp; &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;SslStreamSecurityBindingElement&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;WindowsStreamSecurityBindingElement&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;TcpTransportBindingElement&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Http(s)TransportBindingElement&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;TransportSecurityBindingElement&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;strong&gt;Encoding -&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Text, Binary &lt;br /&gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;strong&gt;Security modes -&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;None, Transport, &lt;/span&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;TransportWithMessageCredential, TransportCredentialOnly (for BasicHttpBinding) &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;/span&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;strong&gt;ClientCredentialType - &lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;None, Basic, Digest, Negotiate, Ntlm, Windows &lt;br /&gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;strong&gt;Transfer Mode - &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Buffered, Streamed, StreamedRequest, and StreamedResponse&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;strong&gt;Serializers -&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;DataContractSerializer, &lt;/span&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;DataContractJsonSerializer, &lt;/span&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;XmlSerializer &lt;br /&gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;strong&gt;Miscellaneous - &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;ChannelFactory&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;DuplexChannelFactory&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;CallbackBehavior&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Thanks!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10227342" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Metro/">Metro</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Windows+8/">Windows 8</category></item><item><title>Calling a WCF service from a Metro application – adding security</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/10/11/calling-a-wcf-service-from-a-metro-application-adding-security.aspx</link><pubDate>Tue, 11 Oct 2011 07:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10223122</guid><dc:creator>PiyushJo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10223122</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/10/11/calling-a-wcf-service-from-a-metro-application-adding-security.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;span style="font-family: verdana; font-size: small;" face="Verdana" size="3"&gt;&lt;span style="font-family: verdana; font-size: x-small;" face="Verdana" size="2"&gt;&lt;span style="color: #ff0000; font-family: Calibri; font-size: medium;" face="Calibri" size="4" color="#ff0000"&gt;&lt;strong&gt;[Updated for Win8/Dev11 Beta]&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;This is an extension to my earlier post - &lt;/span&gt;&lt;a title="http://blogs.msdn.com/b/piyushjo/archive/2011/10/10/calling-a-wcf-service-from-a-metro-application.aspx" href="http://blogs.msdn.com/b/piyushjo/archive/2011/10/10/calling-a-wcf-service-from-a-metro-application.aspx"&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;http://blogs.msdn.com/b/piyushjo/archive/2011/10/10/calling-a-wcf-service-from-a-metro-application.aspx&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt; where I did a walkthrough of calling a WCF service hosted locally on the same machine from a C# Metro client application. In this post, I&amp;rsquo;ll take you through how to add security. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;As you will remember, I had a Picture REST service with webHttpBinding and a ViewCount SOAP service. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Below is a refresher on how to add security to the binding and configuring the respective service hosts with these bindings. &lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8c6ae130-7702-4b77-9db6-ce7373425254" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #fff; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Add service endpoint &amp;amp; webHttp behavior&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebHttpBinding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; webBinding = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebHttpBinding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebHttpSecurityMode&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.TransportCredentialOnly);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;webBinding.Security.Transport.ClientCredentialType = &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClientCredentialType&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Windows;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;pictureServiceHost.AddServiceEndpoint(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IPictureService&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;), webBinding, &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;String&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Empty)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;.EndpointBehaviors.Add(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebHttpBehavior&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;() { HelpEnabled = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;true&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; });&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:aede3a9f-666c-4d5a-9d26-62556a517c0d" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Add service endpoints&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BasicHttpBinding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; basicBinding = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BasicHttpBinding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BasicHttpSecurityMode&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.TransportCredentialOnly);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;basicBinding.Security.Transport.ClientCredentialType = &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClientCredentialType&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Windows;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;viewCountServiceHost.AddServiceEndpoint(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IViewCount&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;), basicBinding, &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;String&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Empty);&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;I am going to use my domain credentials and so I have configured my bindings with SecurityMode of TransportCredentialOnly and HttpClientCredentialType of Windows. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Once you have made the above changes to the service, you need to start up the service host and export metadata for the SOAP service so that we can add service reference to it. When you have completed the Add Service Reference (ASR) action from the metro client application, you will see the following now modified GetBindingForEndpoint method generated on the client (in Reference.cs file, if you do &amp;lsquo;Show all files&amp;rsquo; on the added service reference) which as you can see is already configured for security.&lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d2791081-8874-4056-8d59-a1b7a72b6871" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #ddd; max-height: 400px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;" start="1"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;private&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;static&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; System.ServiceModel.Channels.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Binding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; GetBindingForEndpoint(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;EndpointConfiguration&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; endpointConfiguration) {&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;if&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; ((endpointConfiguration == &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;EndpointConfiguration&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.BasicHttpBinding_IViewCount)) {&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;System.ServiceModel.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BasicHttpBinding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; result = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; System.ServiceModel.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BasicHttpBinding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;();&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;result.AllowCookies = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;true&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;result.Security.Mode = System.ServiceModel.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BasicHttpSecurityMode&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.TransportCredentialOnly;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;result.Security.Transport.ClientCredentialType = System.ServiceModel.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClientCredentialType&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Windows;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; result;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;throw&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; System.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;InvalidOperationException&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Format(&lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"Could not find endpoint with name \'{0}\'."&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, endpointConfiguration));&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;If you are doing this from a non-metro client then equivalents of lines 5 and 6 get generated in xml configuration but since there is no xml styled configuration for metro application, the WCF ASR experience is intelligent enough to generate the equivalent code.&amp;nbsp; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;The above code configuration will enable the proxy to call the SOAP web service providing default domain credentials and you do not have to write any additional piece of code other than instantiating the proxy as we were already doing. &lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c820601d-5772-4dd4-a052-418b76e9f272" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #fff; max-height: 500px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Call the SOAP web service to get details - e.g. view count&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;PhotoService.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ViewCountClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; proxy = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; PhotoService.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ViewCountClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;();&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;That takes care of the SOAP service. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Now for the REST service, we need to configure our HttpClient, which we were using to access the service, to pass the credentials. Here is how you do it:&lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56c32939-b8eb-49b3-9831-738f50144909" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;" start="1"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClientHandler&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; handler = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClientHandler&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;();&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;handler.UseDefaultCredentials = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;true&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; client = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(handler); &lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;You need to instantiate an HttpClientHandler object, configure it to use the default credentials and provide it to the HttpClient so that HttpClient knows that when it gets back an HTTP status code 401 from the service with request for credentials, it needs to pass the default domain credentials. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;And finally, before running the metro client, don&amp;rsquo;t forget to enable the &amp;ldquo;Default Windows Credentials&amp;rdquo; capability which will allow the metro client to retrieve the required domain credentials:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13/2134.Capture.PNG"&gt;&lt;img alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13/2134.Capture.PNG" border="0" /&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1663.image_5F00_4ECA03E5.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;I have modified my REST and SOAP service methods to print the domain credential name passed to the service (using OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name) so you know that the credentials are getting passed correctly!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Sample code attached:&lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:605b2d65-dee4-44d8-ac63-c325d49ec520" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" face="Verdana" size="3"&gt;Thank you!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10223122" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-31-22/DemoCode.zip" length="589846" type="application/zip" /><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Metro/">Metro</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Windows+8/">Windows 8</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Security/">Security</category></item><item><title>Calling a WCF service from a Metro application</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/10/10/calling-a-wcf-service-from-a-metro-application.aspx</link><pubDate>Mon, 10 Oct 2011 00:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10222580</guid><dc:creator>PiyushJo</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10222580</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/10/10/calling-a-wcf-service-from-a-metro-application.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;span style="color: #ff0000; font-family: Calibri; font-size: medium;" size="4" face="Calibri" color="#ff0000"&gt;&lt;strong&gt;[Updated for Win8/Dev11 Beta]&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;In this post, we will do a walkthrough of creating a metro application calling a WCF service hosted locally on the same machine.&amp;nbsp;Note that this is an application development/debug scenario only before you deploy your service on a different machine and this will not be supported for deployed metro applications. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;First &amp;ndash; a bit of an overview about the sample application. The C# metro application will be a photo viewing application with two user scenarios:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;1) Users can view pictures from a source (here the source is going to be a WCF REST service and the metro application will use the new &lt;a href="http://msdn.microsoft.com/en-us/library/hh193681%28v=VS.110%29.aspx" target="_blank"&gt;HttpClient&lt;/a&gt; to connect to the REST service)&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt; &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0676.image_5F00_44C32886.png"&gt;&lt;img width="244" height="140" title="image" style="margin: 0px; display: inline; background-image: none;" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8816.image_5F00_thumb_5F00_3467B0CD.png" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;2) Users can then &amp;lsquo;click&amp;rsquo; or &amp;lsquo;tap&amp;lsquo; (if you are using the touch interface) a picture to get the view count on it (this View count will come from a WCF SOAP service and the metro application will use BasicHttpBinding to receive and send updates on the view count of the picture) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/6355.image_5F00_7AE4A0D5.png"&gt;&lt;img width="244" height="214" title="image" style="margin: 0px; display: inline; background-image: none;" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3125.image_5F00_thumb_5F00_09CBCFF0.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;I am going to use a console application to host both my Picture REST service and ViewCount SOAP service. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;&lt;span style="text-decoration: underline;"&gt;Picture REST service&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div class="class" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a7606178-2535-46c9-ad04-ec2c916224c7" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: 1px solid #000080; color: #000000; font-family: 'Courier New', courier, monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; padding: 2px 5px; color: #ffffff; font-family: verdana, tahoma, arial, sans-serif; font-weight: bold;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #ffffff; overflow: auto; max-height: 300px;"&gt;&lt;ol style="background: #ffffff; margin: 0px; padding: 0px 0px 0px 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;[&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceContract&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;]&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;interface&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IPictureService&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;[&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebGet&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;[] GetPictureIds();&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;[&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebGet&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;]&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Stream&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; GetPicture(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; PictureId);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;The service has two WebGet methods &amp;ndash; one returning all the unique identifiers of the pictures available with the service and the other returning a stream representing the picture associated with a PictureId. [We are assuming that the service already has a collection of fantastic pictures and doesn&amp;rsquo;t need anyone uploading more to it &lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0576.wlEmoticon_2D00_smile_5F00_08F36A06.png" /&gt;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;The implementation of the service is simple though GetPicture implementation might interest you a bit - &lt;/span&gt;&lt;/p&gt;
&lt;div class="class" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6649a243-1f19-4d50-829e-65725bbf1d80" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: 1px solid #000080; color: #000000; font-family: 'Courier New', courier, monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; padding: 2px 5px; color: #ffffff; font-family: verdana, tahoma, arial, sans-serif; font-weight: bold;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #ffffff; overflow: auto; max-height: 300px;"&gt;&lt;ol style="background: #ffffff; margin: 0px; padding: 0px 0px 0px 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Stream&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; GetPicture(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; PictureId)&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;FileStream&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; file = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;FileStream&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(PicturesCollection[PictureId].ToString(), &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;FileMode&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Open);&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebOperationContext&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Current.OutgoingResponse.ContentType = &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"image/jpeg"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; file; &lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="class" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Here I am returning a picture image file whose path is determined by the PictureId and setting the content type of the response to &amp;lsquo;image/jpeg&amp;rsquo;. This is interesting because this will enable any client which knows how to process this content type to automatically do so without any other client programming required &amp;ndash; e.g. if you call this REST service from the browser providing a valid picture id as recognized by this service, the service will return and the browser will automatically display the image file. You can also modify the ContentType to return data of any other format depending on your service. &lt;/span&gt;&lt;/div&gt;
&lt;div class="class" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Hosting the service is akin to what we always do:&lt;/span&gt;&lt;/div&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3b6ade34-b4ad-4469-9dfb-6e79312a52cd" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// ***************&amp;nbsp;&amp;nbsp;&amp;nbsp;PICTURE REST SERVICE&amp;nbsp;&amp;nbsp;&amp;nbsp;***************&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; pictureServiceAddress = &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"http://localhost/PictureService"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebServiceHost&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; pictureServiceHost = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebServiceHost&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;PictureService&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;), &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Uri&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(pictureServiceAddress));&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Add service endpoint &amp;amp; webHttp behavior&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;pictureServiceHost.AddServiceEndpoint(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IPictureService&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;), &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebHttpBinding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(), &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;String&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Empty)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;.EndpointBehaviors.Add(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;WebHttpBehavior&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;() { HelpEnabled = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;true&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; });&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;pictureServiceHost.Open();&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Key pieces as you already might know for WCF REST services are &amp;ndash; open up a &amp;ldquo;WebServiceHost&amp;rdquo;, add a &amp;ldquo;WebHttpBinding&amp;rdquo; and add a &amp;ldquo;WebHttpBehavior&amp;rdquo;. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;&lt;span style="text-decoration: underline;"&gt;ViewCount SOAP Service&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:eab196eb-1f43-412d-9ab6-38b17f8bc333" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;[&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceContract&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;] &lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;interface&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IViewCount&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;[&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;OperationContract&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; GetViewCount(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; PictureId);&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;[&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;OperationContract&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;]&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;void&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; UpdateViewCount(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; PictureId);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;The service has two methods &amp;ndash; one to get the view count of a picture and another to update it based on the Picture Id. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;The only interesting thing about the service is that I am setting ServiceBehavior attribute with InstanceContextMode of single so that all concurrent accesses from multiple clients are processed sequentially to update the view count correctly. &lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cfd5dbc3-1221-4997-a719-381b2c16f105" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Setting instance context to single so that multiple clients can update sequentially&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;[&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceBehavior&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(InstanceContextMode = &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;InstanceContextMode&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Single)]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;class&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ViewCountService&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; : &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IViewCount&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Again, service hosting is in the standard manner using BasicHttpBinding. &lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e094d92-7a2e-4b27-928b-0d244c8fd06b" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// ***************&amp;nbsp;&amp;nbsp;&amp;nbsp;VIEW COUNT SOAP SERVICE&amp;nbsp;&amp;nbsp;&amp;nbsp;***************&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; viewCountServiceAddress = &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"http://localhost/ViewCountService"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceHost&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; viewCountServiceHost = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceHost&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ViewCountService&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;), &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Uri&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(viewCountServiceAddress));&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Add service endpoints&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;viewCountServiceHost.AddServiceEndpoint(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;IViewCount&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;), &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BasicHttpBinding&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(), &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;String&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Empty);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Enable metadata for the service&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceMetadataBehavior&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; metadatBehavior = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ServiceMetadataBehavior&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;();&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;metadatBehavior.HttpGetEnabled = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;true&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;viewCountServiceHost.Description.Behaviors.Add(metadatBehavior);&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;viewCountServiceHost.Open();&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;&lt;span style="text-decoration: underline;"&gt;Metro application&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;This is a C# Windows Metro style application. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;When the application starts up I want to display the images available with the service. So I use an HttpClient to make a request to my REST service and retrieve the Picture Ids and then I use my REST service http url to get the picture associated with each id and assign them to an Image control:&lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:814cb803-aa46-4d4e-942c-4c4cb04e7e33" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;" start="1"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;async&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;void&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; DisplayImages()&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; client = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;();&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Make an Http request to get the Picture Ids from the REST service&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;HttpResponseMessage&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; pictureIdsResponse = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;await&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; client.GetAsync(pictureServiceAddress + &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"/GetPictureIds"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;if&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; (pictureIdsResponse.IsSuccessStatusCode)&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;XDocument&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; document = &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;XDocument&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Parse(pictureIdsResponse.Content.ReadAsStringAsync().Result);&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Parse the picture Ids&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;List&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&amp;gt; PictureIds = (&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;from&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; id &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;in&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; document.Root.Elements()&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&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;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;select&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; id.Value).ToList();&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Assign each image control a picture from the service using an HTTP url.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;image1.Source = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BitmapImage&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Uri&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;String&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Format(&lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"{0}/{1}={2}"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, pictureServiceAddress, &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"GetPicture?PictureId"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, PictureIds[0])));&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Line 6 is where I am making a GET request to get the Picture Ids. The response is by default in Xml format so in Line 9, I am placing the response in an XDocument which I am then querying in line 11 to get the Picture Ids. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;You can also make a call to the REST service from the browser directly with a Url&amp;nbsp; &lt;/span&gt;&lt;a title="http://localhost/PictureService/GetPictureIds" href="http://localhost/PictureService/GetPictureIds"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;http://localhost/PictureService/GetPictureIds&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: verdana;" face="Verdana"&gt;, to get back the Xml response:&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8422.image_5F00_5DAED2FE.png"&gt;&lt;img width="410" height="178" title="image" style="display: inline; background-image: none;" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/2234.image_5F00_thumb_5F00_6461DC81.png" border="0" /&gt;&amp;nbsp;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;or the picture itself - &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4606.image_5F00_1D0C868F.png"&gt;&lt;img width="283" height="268" title="image" style="display: inline; background-image: none;" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/2727.image_5F00_thumb_5F00_01F3B781.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Now to view or update the view count &amp;ndash; we need to access our WCF SOAP service. You need to generate a service reference to &lt;/span&gt;&lt;a title="http://localhost/ViewCountService" href="http://localhost/ViewCountService"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;http://localhost/ViewCountService&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt; using the Add Service Reference (ASR) functionality. I mentioned the key differences in ASR generated code for Metro application in my previous post - &lt;/span&gt;&lt;a title="http://blogs.msdn.com/b/piyushjo/archive/2011/09/22/wcf-in-win8-metro-styled-apps-absolutely-supported.aspx" href="http://blogs.msdn.com/b/piyushjo/archive/2011/09/22/wcf-in-win8-metro-styled-apps-absolutely-supported.aspx"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;http://blogs.msdn.com/b/piyushjo/archive/2011/09/22/wcf-in-win8-metro-styled-apps-absolutely-supported.aspx&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Once the pictures are displayed, I want to display its view count when it is clicked or tapped. So I am using the Tapped event to do so:&lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c68cd190-f961-4e91-ae36-c190ba3db02c" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto;"&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;" start="1"&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;private&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;void&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; image_Tapped(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;object&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; sender, Windows.UI.Xaml.Input.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;TappedEventArgs&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; e)&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;ShowImageDetails(((Windows.UI.Xaml.Controls.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Image&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;)sender).Tag.ToString()); &lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;async&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;void&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; ShowImageDetails(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;string&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; PictureId)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Set the description image&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;imageDetails.Source = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;BitmapImage&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;Uri&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;(&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;String&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Format(&lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"{0}/{1}={2}"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, pictureServiceAddress, &lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"GetPicture?PictureId"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, PictureId)));&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Call the SOAP web service to get details - e.g. view count&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;PhotoService.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ViewCountClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; proxy = &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; PhotoService.&lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;ViewCountClient&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;();&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// Update the view count with the current view&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;await&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; proxy.UpdateViewCountAsync(PictureId);&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #008000;"&gt;// And display the count&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;ViewCount.Text = &lt;/span&gt;&lt;span style="background: #ffffff; color: #2b91af;"&gt;String&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;.Format(&lt;/span&gt;&lt;span style="background: #ffffff; color: #a31515;"&gt;"View Count = {0}"&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;, &lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;await&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; proxy.GetViewCountAsync(PictureId));&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background: #f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background: #ffffff; color: #000000;"&gt;&lt;/span&gt;&lt;span style="background: #ffffff; color: #0000ff;"&gt;await&lt;/span&gt;&lt;span style="background: #ffffff; color: #000000;"&gt; proxy.CloseAsync();&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: #ffffff; color: #000000;"&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;In Line 12, I am creating a proxy to my ViewCount SOAP service. In line 15, I am calling the UpdateViewCount method to go and update the view count for this Picture Id as someone tapped it to view it. And finally in line 18, I am getting the latest view count for this Picture Id by calling the GetViewCount method. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;I have attached the service and the metro application solution. Both the REST and the SOAP services are hosted in the same console application and thus the same process. This service solution also contains a ConsoleClient to simulate a concurrently calling client which you can use to update the view count of pictures in the service which will then reflect in the Metro client UI when the metro client next calls the service. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;The following is not needed anymore from BETA onwards and an exemption is automatically added while debugging from Visual Studio. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;So now &amp;ndash; you run the service and you run the metro client but you get - &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;System.Net.Http.HttpRequestException {"An error occurred while sending the request."} "Unable to connect to the remote server"&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;with the inner exception of&lt;/span&gt; {"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 127.0.0.1:80"}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;&lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0576.wlEmoticon_2D00_smile_5F00_08F36A06.png" /&gt; If it would have been straightforward &amp;ndash; I wouldn&amp;rsquo;t be writing this blog post, now would I? By default, metro client access to loopback address is blocked for network isolation. See more here - &lt;a title="http://msdn.microsoft.com/en-us/library/windows/apps/hh452759(v=vs.85).aspx" href="http://msdn.microsoft.com/en-us/library/windows/apps/hh452759(v=vs.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/windows/apps/hh452759(v=vs.85).aspx&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;So what do you do &amp;ndash; you need to run the CheckNetworkIsolation.exe tool described in the above MSDN link like the following:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;code&gt;CheckNetIsolation.exe LoopbackExempt &amp;ndash;a &amp;ndash;n=&amp;rdquo;PackageFamilyName&amp;rdquo;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;code&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;This will add an exemption for our metro application to access the loopback address. &lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;code&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;You may ask &amp;ndash; how do I get this PackageMonikerName. For this - you need to open up the app manifest file:&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4606.image_5F00_3312F221.png"&gt;&lt;img width="347" height="248" title="image" style="display: inline; background-image: none;" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0167.image_5F00_thumb_5F00_00AF1EA2.png" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Not only this, I also had to open up the firewall for the TCP port my service is listening by creating an Inbound rule. This is required on the BUILD preview Win8 release. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;&lt;span style="font-family: verdana; font-size: small;" size="3" face="Verdana"&gt;Once you have done the above two steps &amp;ndash; adding an exemption for your metro app and creating a firewall rule, the metro client should be able to connect to the locally hosted web services. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:3927a3a7-f9a0-429b-ac4b-6de3d0de2120" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;&lt;/div&gt;
&amp;nbsp;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: small;" size="3" face="Verdana"&gt;Thank you!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10222580" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-25-80/Sample.zip" length="601723" type="application/zip" /><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Metro/">Metro</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Windows+8/">Windows 8</category></item><item><title>What’s new in WCF 4.5 – generated client config cleaned</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/10/05/what-s-new-in-wcf-4-5-tidied-up-generated-client-config.aspx</link><pubDate>Wed, 05 Oct 2011 08:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10220305</guid><dc:creator>PiyushJo</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10220305</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/10/05/what-s-new-in-wcf-4-5-tidied-up-generated-client-config.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;One of our primary focuses this release was to simplify working with WCF. Configuration simplicity was right at the top since we know most of you find configuration hard and confusing. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;We will talk about the configuration improvements in separate detailed posts but I wanted to highlight couple of small improvements in 4.5. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;strong&gt;1) Reduced the mammoth client side generated config to only non-default values:&lt;/strong&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;Well, if you are a WCF user, you would have definitely used the &amp;ldquo;Add Service Reference&amp;rdquo; (ASR) functionality or used svcutil.exe to point to a service WSDL to generate a service reference and associated configuration required to call the service. I bet, you would have also noticed the huge configuration file where we used to dump all the binding properties and trust me, WCF has quite a few of these&lt;img style="border-style: none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1616.wlEmoticon_2D00_smile_5F00_7AD467F9.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;To remind you of the ugly sight which present you &amp;ndash; here is what you get today with Visual Studio 2010 when you generate a service reference for a simple WCF service with a single endpoint and basicHttpBinding:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5584.image_5F00_6576B291.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1803.image_5F00_thumb_5F00_650A7F9C.png" width="560" height="331" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;In Visual Studio 2011, we have fixed this and when you generate a service reference &amp;ndash; you will get much neater and cleaner config file which we hope, you will find much simpler: &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4431.image_5F00_525585E5.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8156.image_5F00_thumb_5F00_44170CF5.png" width="565" height="154" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;Notice that the entire binding section has been trimmed down. We will only generate non-default values here so say for e.g. I changed the message encoding on the service to &amp;ldquo;Mtom&amp;rdquo; and I regenerate the service reference on the client &amp;ndash; I will get the following. &lt;span style="font-size: small;" size="3"&gt;Notice that we have generated only the non-default value of messageEncoding here. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4011.image_5F00_7CC1B702.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/8737.image_5F00_thumb_5F00_0374C086.png" width="574" height="128" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;While on the topic of discovering little gems around configuration &amp;ndash; here is another one. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;strong&gt;2) Made the WCF config editor easily discoverable &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;This was one of my pet peeves. I really like the &lt;a href="http://msdn.microsoft.com/en-us/library/ms732009.aspx" target="_blank"&gt;Configuration editor tool&lt;/a&gt; even though it is not as powerful as it could be. Even in its current form, it allows me to make configuration changes easily without requiring me to remember every config property WCF has to offer by its name and location. We have shipped this tool in the previous releases and yet, very few folks actually know about it let alone use it. And one of the key reasons was that we used to hide it somewhere in the tools menu where very few folks poke around. Once you have opened the configuration file via this tool, a right click context menu item belatedly used to appear for the configuration file to allow easy access thereafter. But &amp;ndash; good luck finding it the first time!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;Now it is available as a right click gesture right there on the config file from the time you open up a new WCF project as &amp;ldquo;WCF Service application&amp;rdquo; or &amp;ldquo;WCF Service library&amp;rdquo; templates. So hopefully, you can find it and use it more often!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;Thank you!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10220305" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF+4-5/">WCF 4.5</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Configuration/">Configuration</category></item><item><title>What’s new in WCF 4.5 – Flat WSDL support</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/10/05/what-s-new-in-wcf-4-5-flat-wsdl-support.aspx</link><pubDate>Wed, 05 Oct 2011 06:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10220270</guid><dc:creator>PiyushJo</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10220270</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/10/05/what-s-new-in-wcf-4-5-flat-wsdl-support.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;As I promised &amp;ndash; I&amp;rsquo;ll be blogging about the new features introduced in WCF 4.5 here. Before getting into big features, lets start with a few small gems. &lt;/span&gt;&lt;span style="font-size: small;" size="3"&gt;The first one is the support for Flat WSDL! &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;Interoperability with non-.NET stacks has always been important to us at WCF and there have been instances where some such clients haven&amp;rsquo;t been able to consume the WSDL generated from a WCF service. WCF, by default generates a WSDL in modular format. This means that the WSDL document specifies its dependencies via xsd:import attributes. Schema types in particular are always generated as separate XSD files. If you look at a typical WSDL file generated by a WCF service &amp;ndash; here is what you will notice near the top section. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4454.WSDL_5F00_59107091.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="WSDL" border="0" alt="WSDL" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0638.WSDL_5F00_thumb_5F00_50AC9B3A.png" width="642" height="89" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;Modular WSDL while having its advantages, is not understood by some of the non-.Net stacks leading to interoperability issues. Customers implemented tedious workarounds to make this all work. Not anymore! Enter the support for Flat WSDL in WCF. This means, as you would have guessed by its name, there is a single WSDL document and no external references to schema types or anything else. I am attaching a 4.0 generated modular WSDL and the corresponding flat WSDL with the blog post so that you can compare and see the difference yourself. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;What this means:&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-size: small;" size="3"&gt;Improved interoperability support for all the third party WSDL processing stacks like PHP, Flex, Powerbuilder or Infopath which have been unable in the past to consume a WCF modular WSDL without running into issues. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;" size="3"&gt;No more problems when the xsd:import referred to some internal location because say the WCF service was behind a firewall producing a WSDL with schemaLocations pointing to unresolvable URIs and thereby requiring manual correction in the entire downloaded WSDL and all the referenced files as well. I have done that and it as terrible! &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;" size="3"&gt;No more dealing with a whole boatload of files when downloading the metadata from a complex service now that the entire metadata is contained within a single WSDL file now. &lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;So, you ask &amp;ndash; what do I have to do to take advantage of this fantastic feature &amp;ndash; well the answer, as Seinfeld would put it - is &amp;ldquo;Nothing&amp;rdquo;. You just enable metadata how you have always done by enabling the serviceMetadata attribute for a 4.5 service and you will see the following &amp;ldquo;additional&amp;rdquo; link on your now familiar metadata description page - &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5025.SingleWsdl_5F00_0F9E1BD6.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="SingleWsdl" border="0" alt="SingleWsdl" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/4848.SingleWsdl_5F00_thumb_5F00_7636189B.png" width="580" height="126" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;You can continue to import the WSDL as you have always done if you do not need the flat WSDL support. However if you do need WSDL in the flat format &amp;ndash; you get it from the second link &amp;ndash; notice the ?singleWsdl at the end instead of ?wsdl. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;Thanks. &lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10220270" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-02-70/WSDLs.zip" length="2435" type="application/zip" /><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF+4-5/">WCF 4.5</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WSDL/">WSDL</category></item><item><title>Azure Service Bus–working with the appfabriclabs account</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/09/27/azure-service-bus-working-with-the-appfabriclabs-account.aspx</link><pubDate>Tue, 27 Sep 2011 08:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10217075</guid><dc:creator>PiyushJo</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10217075</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/09/27/azure-service-bus-working-with-the-appfabriclabs-account.aspx#comments</comments><description>&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;So I have been playing with &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/ee732537.aspx" target="_blank"&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;Azure Service Bus&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt; lately. I have created an Azure AppFabric Labs account for myself and this allows me to easily get started with and try Azure AppFabric services like Service Bus, Access Control Service and Cache for my sample applications. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;When I started with my first basic Service Bus sample which simply creates a WCF service and registers itself to the Service Bus to enable the queue to listen for messages, I ran into couple of interesting issues which took a bit of online search time to figure out. I am describing the solution here in case anyone else finds themselves in the same shoes as mine. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;First - I got the following error when I started my simple WCF service host.&amp;nbsp; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana;" face="Verdana"&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-size: x-small;" size="2"&gt;&amp;ldquo;The token provider was unable to provide a security token while accessing '&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;a href="https://&lt;myNamespace&gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-size: x-small;" size="2"&gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&amp;gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&amp;gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&amp;gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&amp;gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&amp;gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&amp;gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&amp;gt;-sb.accesscontrol.windows.net/WRAPv0.9/'"&amp;gt;https://&amp;lt;myNamespace&amp;gt;-sb.accesscontrol.windows.net/WRAPv0.9/'&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-size: x-small;" size="2"&gt;. Token provider returned message: 'Unable to connect to the remote server'.&amp;rdquo; &lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;I figured that this is because my service bus namespace is situated in labs environment. So I modified the code while creating the service address to replace the domain:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: green;"&gt;// Create the service uri based on service namespace &lt;/span&gt;&lt;span style="color: #2b91af;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="color: #2b91af;"&gt;Uri &lt;/span&gt;serviceAddress = &lt;span style="color: #2b91af;"&gt;ServiceBusEnvironment&lt;/span&gt;.CreateServiceUri (&lt;span style="color: #a31515;"&gt;"sb"&lt;/span&gt;, serviceNamespace, &lt;span style="color: #a31515;"&gt;"MyEchoService"&lt;/span&gt;);&lt;/span&gt;&lt;span style="font-size: small;" size="3"&gt;serviceAddress = &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af;"&gt;Uri&lt;/span&gt;(serviceAddress.ToString().Replace (&lt;span style="color: #a31515;"&gt;"windows.net"&lt;/span&gt;, &lt;span style="color: #a31515;"&gt;"appfabriclabs.com"&lt;/span&gt;)); &lt;/span&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;However, even after my above fix, the problem didn't go away and I ran into another error message: &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;&lt;em&gt;&lt;strong&gt;uri provided &amp;lt;myNamespace&amp;gt;.servicebus.appfabriclabs.com does not match service bus domain: servicebus.windows.net&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;It turns out that the fix to redirect from servicebus.windows.net to servicebus.appfabriclabs.com environment is simple once you know it and there is no change in code required, not even correcting the service address bit I did above. All you need to do is to create an xml file named ServiceBus.xml with the following content in the &amp;hellip;\Microsoft.Net\Framework(64)\&amp;lt;version&amp;gt;\Config directory:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #a31515;"&gt;xml &lt;/span&gt;&lt;span style="color: red;"&gt;version&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;1.0&lt;/span&gt;" &lt;span style="color: red;"&gt;encoding&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;utf-8&lt;/span&gt;"&lt;span style="color: blue;"&gt;?&amp;gt; &amp;lt;!-- &lt;/span&gt;&lt;span style="color: green;"&gt;the root web configuration file &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: blue;"&gt;--&amp;gt; &lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;configuration&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Microsoft.ServiceBus&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;relayHostName&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;servicebus.appfabriclabs.com&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;relayHostName&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;stsHostName&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;accesscontrol.appfabriclabs.com&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;stsHostName&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: blue;"&gt;&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;acmHostName&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;accesscontrol.appfabriclabs.com&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;acmHostName&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Microsoft.ServiceBus&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;configuration&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-size: x-small;" size="2"&gt; &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana;" face="Verdana"&gt;&lt;span style="font-size: x-small;" size="2"&gt;More on this here - &lt;/span&gt;&lt;a title="http://abhishekrlal.wordpress.com/2011/03/22/clientsdkconfig/" href="http://abhishekrlal.wordpress.com/2011/03/22/clientsdkconfig/"&gt;&lt;span style="font-size: x-small;" size="2"&gt;http://abhishekrlal.wordpress.com/2011/03/22/clientsdkconfig/&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small;" size="2"&gt;. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"&gt;There is a catch though &amp;ndash; you should also check the &amp;ldquo;Platform target&amp;rdquo; setting of your application before deciding where to put this ServiceBus.config. If your application is set to AnyCPU, which is the default, then on a 64 bit machine you will put the above ServiceBus.config in the Framework64\&amp;hellip;\Config directory otherwise in the Framework\&amp;hellip;\Config directory. However if the Platform target is explicitly set, then you will need to place the file depending on the setting here &amp;ndash; e.g. if Platform target is set to x86, then even on a 64 bit machine &amp;ndash; above config file will go in the Framework\&amp;hellip;\Config (and not Framework64\&amp;hellip;\Config) directory. &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3051.image_5F00_11693A10.png"&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/7268.image_5F00_25EE898E.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5187.image_5F00_thumb_5F00_33E23128.png" width="449" height="184" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: Verdana;" face="Verdana"&gt;&lt;/span&gt;&lt;span style="font-size: x-small;" size="2"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10217075" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Service+Bus/">Service Bus</category></item><item><title>WCF in Windows 8 Metro styled apps? Absolutely supported</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/09/22/wcf-in-win8-metro-styled-apps-absolutely-supported.aspx</link><pubDate>Thu, 22 Sep 2011 05:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10215162</guid><dc:creator>PiyushJo</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10215162</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/09/22/wcf-in-win8-metro-styled-apps-absolutely-supported.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font color="#ff0000" size="4" face="Calibri"&gt;&lt;strong&gt;[Updated for Win8/Dev11 Beta]&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;Hi all,        &lt;br /&gt;With Windows 8 metro styled applications getting a great buzz - I thought this was a perfect time to introduce the WCF support for Metro applications.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;We provide support for WCF client inside a Metro application with a subset of features compared to classic desktop applications. See here - &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&lt;a href="http://blogs.msdn.com/b/piyushjo/archive/2011/10/19/wcf-for-metro-apps-supported-functionality.aspx"&gt;http://blogs.msdn.com/b/piyushjo/archive/2011/10/19/wcf-for-metro-apps-supported-functionality.aspx&lt;/a&gt; &lt;/font&gt; for the supported feature list. &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;This enables you to consume all those awesome web services out there, in your metro app very easily and as we will see – very similar to what you are already used to. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;We will start with a simple Metro application in C# and consume an ASMX web service (one of the first weather services I found in my search results). The application in its current form will be a simple weather reporting client taking in a US zip code and displaying the weather by calling an external web service hosted here - &lt;/font&gt;&lt;/span&gt;&lt;a href="http://wsf.cdyne.com/WeatherWS/Weather.asmx"&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;http://wsf.cdyne.com/WeatherWS/Weather.asmx&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;.&amp;#160; The point of the demo is to clarify the client experience for Win8 Metro app.        &lt;br /&gt;In future blog posts, we will extend the application to include more of supported WCF features and will consume WCF services which is likely going to be the norm. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/6761.image_5F00_4673D947.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/2548.image_5F00_thumb_5F00_3EE869DA.png" width="226" height="266" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;1. Open Visual Studio 11 and create a new Windows Metro style Blank application. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5265.image_5F00_536DB958.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3124.image_5F00_thumb_5F00_3C423EDA.png" width="442" height="179" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;2. In your application - right click on References and add the service reference to &lt;/font&gt;&lt;/span&gt;&lt;a href="http://wsf.cdyne.com/WeatherWS/Weather.asmx"&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;http://wsf.cdyne.com/WeatherWS/Weather.asmx&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt; service just as you do for classic desktop apps. This will generate a service reference to this weather service. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/3122.image_5F00_19ED3A12.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/2538.image_5F00_thumb_5F00_67896692.png" width="441" height="357" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;3. So far nothing out of the ordinary - everything is exactly the same as what we are used to while adding a service reference to a web service.        &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;The fun starts now:        &lt;br /&gt;a) First note that there is no configuration file generated. Metro apps do not support the traditional xml styled application so we have modified our Add Service Reference (ASR) experience from within a metro app to generate code based configuration.         &lt;br /&gt;Where will you find this generated code? Go to the Reference.cs file generated under the service reference folder. You will have to click &amp;quot;Show All Files&amp;quot; in Solution explorer.         &lt;br /&gt;You will see code like the following for the generated binding and endpoint address: &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&amp;#160;&amp;#160; &lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1dbebc17-e833-4dbb-92c9-bf69b564664e" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;static&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; System.ServiceModel.Channels.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Binding&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; GetBindingForEndpoint(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;EndpointConfiguration&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; endpointConfiguration) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ((endpointConfiguration == &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;EndpointConfiguration&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.WeatherSoap)) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;System.ServiceModel.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;BasicHttpBinding&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; result = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; System.ServiceModel.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;BasicHttpBinding&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;result.MaxBufferSize = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.MaxValue;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;result.ReaderQuotas = System.Xml.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;XmlDictionaryReaderQuotas&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Max;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;result.MaxReceivedMessageSize = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.MaxValue;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;result.AllowCookies = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; result;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;throw&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; System.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;InvalidOperationException&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Format(&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;&amp;quot;Could not find endpoint with name &amp;#92;&amp;#39;{0}&amp;#92;&amp;#39;.&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, endpointConfiguration));&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;static&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; System.ServiceModel.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;EndpointAddress&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; GetEndpointAddress(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;EndpointConfiguration&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; endpointConfiguration) {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ((endpointConfiguration == &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;EndpointConfiguration&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.WeatherSoap)) {&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; System.ServiceModel.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;EndpointAddress&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;&amp;quot;http://wsf.cdyne.com/WeatherWS/Weather.asmx&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;throw&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; System.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;InvalidOperationException&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Format(&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;&amp;quot;Could not find endpoint with name &amp;#92;&amp;#39;{0}&amp;#92;&amp;#39;.&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, endpointConfiguration));&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;    &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;div class="csharpcode"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;    &lt;p&gt;&lt;font face="Calibri"&gt;&lt;font size="3"&gt;&lt;span class="lnum"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;/div&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;Now this also means that if you need to change any binding properties on the client side - you need to do this in code. You can use the newly generated partial method ‘ConfigureEndpoint’ to implement any changes outside the generated proxy class so that you can update the generated proxy (including Reference.cs) without any fear of your changes being overwritten. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4f296f56-8f7c-4749-99ad-df466062999c" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;partial&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;WeatherSoapClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; : System.ServiceModel.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ClientBase&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;MetroTestApp.WeatherService.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;WeatherSoap&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt;, MetroTestApp.WeatherService.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;WeatherSoap&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; {&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;///&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;///&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt; Implement this partial method to configure the service endpoint.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;///&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;///&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;&amp;lt;param name=&amp;quot;serviceEndpoint&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;The endpoint to configure&lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;///&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;&amp;lt;param name=&amp;quot;clientCredentials&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#008000"&gt;The client credentials&lt;/span&gt;&lt;span style="background:#ffffff;color:#808080"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;static&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;partial&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; ConfigureEndpoint(System.ServiceModel.Description.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ServiceEndpoint&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; serviceEndpoint, System.ServiceModel.Description.&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ClientCredentials&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; clientCredentials);&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;b) Next - you will also notice a difference in the style of operations generated for the service.        &lt;br /&gt;Note that you &lt;strong&gt;only&lt;/strong&gt; have task based async patterned methods generated. This ensures that there are no blocking calls from the metro styled UI apps, even unknowingly.         &lt;br /&gt;If you will generate a similar service reference from a classic desktop app in Dev11 - you will see both synchronous and task based async methods. Task based async pattern is the recommended pattern for doing async programming going forward therefore in Add Service Reference - Advanced dialog, we select it for you by default:&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1067.image_5F00_02558C9F.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/0804.image_5F00_thumb_5F00_2BCC5E90.png" width="498" height="121" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;4) That’s it. Thereafter you can call the service asyn using the following Task based async model: &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:76c0e741-b039-453a-a41f-683c8bd69dfc" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;async&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; GoButton_Click(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; sender, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; e)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;WeatherSoapClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; proxy = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;WeatherSoapClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;WeatherReturn&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; result = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;await&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; proxy.GetCityWeatherByZIPAsync(inputZipCode.Text);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (result.Success)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;resultCityState.Text = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;String&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Format(&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;&amp;quot;{0}, {1}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, result.City, result.State);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;resultDetails.Text = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;String&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Format&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;&amp;quot;&amp;#92;nConditions - {0} &amp;#92;nTemperature - {1}F &amp;#92;nRelative Humidity - {2} &amp;#92;nWind - {3} &amp;#92;nPressure - {4}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;result.Description, result.Temperature, result.RelativeHumidity, result.Wind, result.Pressure);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;resultCityState.Text = &lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;&amp;quot;City not found&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;div class="csharpcode"&gt;&amp;#160;&lt;/div&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;div class="csharpcode"&gt;&lt;font size="3" face="Calibri"&gt;Note that the method is marked async and we are making the service call with the await keyword. &lt;/font&gt;&lt;/div&gt;  &lt;div class="csharpcode"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/div&gt;  &lt;div class="csharpcode"&gt;&lt;font size="3" face="Calibri"&gt;5) You don’t have to provide any additional capability and the default capability Internet (Client) is sufficient. &lt;/font&gt;&lt;/div&gt;  &lt;div class="csharpcode"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1067.image_5F00_445BFBE0.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/1452.image_5F00_thumb_5F00_344FBDDA.png" width="488" height="222" /&gt;&lt;/a&gt;&lt;/div&gt;  &lt;div class="csharpcode"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/div&gt;  &lt;div class="csharpcode"&gt;&lt;font size="3" face="Calibri"&gt;So that was pretty much it! For you - while developing metro apps - you just need to be aware that: &lt;/font&gt;&lt;/div&gt;  &lt;div class="csharpcode"&gt;&lt;font size="3" face="Calibri"&gt;     &lt;br /&gt;1) You need to make all configuration in code.       &lt;br /&gt;2) You need to make all service calls async using the task based pattern.&lt;/font&gt;&lt;/div&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;Attached is a sample app which contains two projects - one is a metro styled app and another a regular console app making the same service call. You can compare the generated service references to get more insight. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;   &lt;br /&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;Sample code attached.&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:60f2605c-7745-4983-b3c4-c354f8e71ea6" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt;&lt;p&gt; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-09-13-metablogapi/5432.MetroTestApp_5F00_3B14CC7D.zip" target="_blank"&gt;MetroSimpleSample&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;/span&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: verdana; font-size: x-small;" size="2" face="Verdana"&gt;&lt;font size="3" face="Calibri"&gt;Thanks!&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10215162" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-21-51-62/MetroTestApp.zip" length="232169" type="application/zip" /><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Metro/">Metro</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/Windows+8/">Windows 8</category></item><item><title>Visual Studio 2011 and .Net framework 4.5 announced at BUILD conference</title><link>http://blogs.msdn.com/b/piyushjo/archive/2011/09/20/visual-studio-2011-and-net-framework-4-5-announced-at-build-conference.aspx</link><pubDate>Tue, 20 Sep 2011 06:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10213908</guid><dc:creator>PiyushJo</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/piyushjo/rsscomments.aspx?WeblogPostID=10213908</wfw:commentRss><comments>http://blogs.msdn.com/b/piyushjo/archive/2011/09/20/visual-studio-2011-and-net-framework-4-5-announced-at-build-conference.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hi everyone,&lt;/p&gt;
&lt;p&gt;As you all know that we announced Visual Studio 2011 and the next framework version v4.5 at BUILD conference last week.&lt;/p&gt;
&lt;p&gt;Please note that we are using the combined forum here - &lt;a href="http://forums.asp.net/1239.aspx/1?ASP+NET+4+5+Developer+Preview+and+Visual+Studio+11+Developer+Preview"&gt;http://forums.asp.net/1239.aspx/1?ASP+NET+4+5+Developer+Preview+and+Visual+Studio+11+Developer+Preview&lt;/a&gt; for answering all WCF v4.5 preview related questions. Please post all such questions there to get quick set of eyes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WCF v4.5 feature list:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Here is a quick list of features/enhancements we are bringing in WCF v4.5, your feedback is welcome. I will be blogging about these in detail in the next few days.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Scalable modern communication stack&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;- Scalable, bi-directional communication over HTTP using WebSockets&lt;/p&gt;
&lt;p&gt;- Interoperable public UDP multi-cast channel&lt;/p&gt;
&lt;p&gt;- TCP support for high-density scenarios (partial trust)&lt;/p&gt;
&lt;p&gt;- Support for Tasks and the new C# Async language features throughout WCF programming model&lt;/p&gt;
&lt;p&gt;- Improved streaming support&lt;/p&gt;
&lt;p&gt;- Compression support (gzip/deflate) for binary encoding&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Continued commitment to simplicity&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;- Further config simplification, config intellisense, making WCF throttles/quotas smarter &amp;amp; work for you by default!&lt;/p&gt;
&lt;p&gt;- Support for multiple authentication modes on a single WCF endpoint&lt;/p&gt;
&lt;p&gt;- Better manageability via rich ETW &amp;amp; e2e tracing&lt;/p&gt;
&lt;p&gt;- XSD-first type authoring experience&lt;/p&gt;
&lt;p&gt;- Support for Internationalized Domain Name (IDN) WCF services.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Win8&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Support for WCF client in Win8 immersive applications with basicHttp/netTcp/WebSocket* bindings.&lt;/p&gt;
&lt;p&gt;[*WebSocket support for Win8 WCF Immersive apps is not present in the current preview release but we are working to add it in the final 4.5 release]&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Interesting BUILD talks&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;1) Building Web APIs in Windows Azure with WCF to reach any device - &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-798T"&gt;http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-798T&lt;/a&gt;&amp;nbsp; , Glenn Block&lt;/p&gt;
&lt;p&gt;2) Building real-time web apps with WebSockets using IIS, ASP.NET and WCF &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-807T"&gt;http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-807T&lt;/a&gt; , Paul Batum, Stefan Schackow&lt;/p&gt;
&lt;p&gt;3) Building data-driven HTML5 apps with WCF RIA Services &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-800T"&gt;http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-800T&lt;/a&gt; , Dinesh Kulkarni&lt;/p&gt;
&lt;p&gt;4) Building real-time web apps with HTML5 WebSockets &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-373C"&gt;http://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-373C&lt;/a&gt; , Ravi Rao&lt;/p&gt;
&lt;p&gt;5) What's new in .NET Framework 4.5 &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-834T"&gt;http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-834T&lt;/a&gt; , Joshua Goodman&lt;/p&gt;
&lt;p&gt;6) Building and running HPC apps in Windows Azure &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-452T"&gt;http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-452T&lt;/a&gt; , Greg Burgess.&lt;/p&gt;
&lt;p&gt;Thanks and please do tell us which features excite you the most!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10213908" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/piyushjo/archive/tags/WCF+4-5/">WCF 4.5</category></item></channel></rss>