<?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>Justin Smith's Blog : WCF</title><link>http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx</link><description>Tags: WCF</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>enableWebScript, UriTemplate, and HTTP methods</title><link>http://blogs.msdn.com/justinjsmith/archive/2008/02/15/enablewebscript-uritemplate-and-http-methods.aspx</link><pubDate>Sat, 16 Feb 2008 02:55:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7724901</guid><dc:creator>justinjsmith</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/7724901.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=7724901</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=7724901</wfw:comment><description>&lt;p&gt;A little while ago I ran into an interesting set of errors that may be of interest to you. Consider the following service contract snippet:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;[OperationContract]
[WebGet(UriTemplate=&lt;span class="str"&gt;&amp;quot;foobar/{value}&amp;quot;&lt;/span&gt;)]
&lt;span class="kwrd"&gt;String&lt;/span&gt; GetData(String &lt;span class="kwrd"&gt;value&lt;/span&gt;);&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;If you add the enableWebScript behavior to an endpoint that is using the WebHttpBinding, you will see this exception when the ServiceHost starts:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;System.InvalidOperationException: Endpoints using 'UriTemplate' cannot be used with 'System.ServiceModel.Description.WebScriptEnablingBehavior'.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The reason for this error is rooted in the origin of the enableWebScript behavior. One of it's design objectives was to simplify working with the ASP.NET AJAX stack (Javascript proxy, JSON messages, etc). The AJAX stack doesn't have the equivalent of the UriTempalte type. It simply puts parameters in query strings (gets) and constructs entity bodies (posts). This is the default behavior of the WCF stack when the WebGet / WebInvoke annotations do not have a value for UriTemplate. Since any value of UriTemplate would be incompatible with the ASP.NET AJAX stack, we throw when it's present.&lt;/p&gt;

&lt;p&gt;If you want JSON messages from a contract and you want to use the UriTemplate niceness, you can change your contract to:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[OperationContract]
[WebGet(UriTemplate=&lt;span class="str"&gt;&amp;quot;foobar/{value}&amp;quot;&lt;/span&gt;, ResponseFormat=WebMessageFormat.Json)]
&lt;span class="kwrd"&gt;String&lt;/span&gt; GetData(S&lt;span class="kwrd"&gt;tring&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;);&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Then, instead of using the enableWebScript behavior, use the WebHttpBehavior. You'll lose compat with the ASP.NET AJAX client stack (and the JS proxy), but you have the URI you are looking for.&lt;/p&gt;

&lt;p&gt;The same is true if you are using the WebInvoke attribute and any HTTP method other than POST. The AJAX client stack only knows GET and POST...&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7724901" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/JSON/default.aspx">JSON</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/ASP.NET+AJAX/default.aspx">ASP.NET AJAX</category></item><item><title>MySpace does WCF</title><link>http://blogs.msdn.com/justinjsmith/archive/2008/01/31/myspace-does-wcf.aspx</link><pubDate>Fri, 01 Feb 2008 07:12:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7366363</guid><dc:creator>justinjsmith</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/7366363.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=7366363</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=7366363</wfw:comment><description>&lt;p&gt;My friend Vittorio has posted that MySpace will be talking about WCF at Mix 2008 (&lt;a href="http://blogs.msdn.com/vbertocci/archive/2008/01/31/wcf-and-myspace-a-restful-mix-session.aspx"&gt;see it here&lt;/a&gt;). This promises to be a good session!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7366363" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Syndication/default.aspx">Syndication</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category></item><item><title>Life of a WCF Demo, Part 1</title><link>http://blogs.msdn.com/justinjsmith/archive/2008/01/22/life-of-a-wcf-demo-part-1.aspx</link><pubDate>Wed, 23 Jan 2008 02:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7202858</guid><dc:creator>justinjsmith</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/7202858.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=7202858</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=7202858</wfw:comment><description>&lt;P&gt;I thought it might be mildly interesting to document the lifecycle of a demo. Over the next week or so I have to design, build, and deploy a demo that shows off some of the web-centric features of WCF in the .NET Framework 3.5. First, let me state the constraints:&lt;/P&gt;
&lt;P&gt;1) it has to be lightweight - a person in the field or in the community must be able to run it with a bare bones setup (VS only)&lt;/P&gt;
&lt;P&gt;2) it has to be "codable" from the ground up in a short period of time w/o much practice&lt;/P&gt;
&lt;P&gt;3) it has to show off the new HTTP programming model, Syndication, and JSON messaging.&lt;/P&gt;
&lt;P&gt;4) it should also bring to the surface other WCF features like new tooling, flexible configuration options, etc.&lt;/P&gt;
&lt;P&gt;5) ideally, a silverlight client consumes the services.&lt;/P&gt;
&lt;P&gt;I'm not sure how many parts it will take to blog this. Time will tell.&lt;/P&gt;
&lt;P&gt;Since the demo is supposed to be lightweight and it has to be codable, it is going to lack the "real life" aspect. Simplicity and demos and reflecting real world scenarios are often in conflict in demos. Since this is not going to be a keynote, there is no need to dwell on it too long.&lt;/P&gt;
&lt;P&gt;With that in mind, I will build an album metadata sharing service. The service just returns information about albums in a store and provides consumers with some ability to create side effects (add, change, or delete an album). Because the demo is supposed to be codable, we will keep the album type definition simple, maybe just a few fields. &lt;/P&gt;
&lt;P&gt;There will likely need to be a backing store for the album data, so we have to decide where to store album data. Since DB connections can be annoying to deploy to lots of people, I will opt for an XML File in a VS project.&lt;/P&gt;
&lt;P&gt;In regards to project structure, the VS solution will have 2 projects: AlbumService (WCF Service) and AlbumClient (Silverlight app). If we are feeling spunky, we can also build an ASP.NET AJAX app that uses the service.&lt;/P&gt;
&lt;P&gt;Now it's time to code. I've found it's important to document any hiccups that occur along the way, and be certain those get communicated to the people that may present the demo in the future. I use a simple MS Word document. In this case, I am using LiveWriter, and posting it to my blog :).&lt;/P&gt;
&lt;H3&gt;Step 1: Create a VS Solution&lt;/H3&gt;
&lt;P&gt;Easy enough. &lt;/P&gt;
&lt;H3&gt;Step 2: Create a WCF Class Library Project&lt;/H3&gt;
&lt;P&gt;VS 2008 includes some new WCF tooling. You basically go to File-&amp;gt;New-&amp;gt;Project-&amp;gt;WCF-&amp;gt;WCF Service Library.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=175 alt=img1 src="http://blogs.msdn.com/blogfiles/justinjsmith/WindowsLiveWriter/LifeofaWCFDemoPart1_CDB6/img1_3.png" width=640 border=0 mce_src="http://blogs.msdn.com/blogfiles/justinjsmith/WindowsLiveWriter/LifeofaWCFDemoPart1_CDB6/img1_3.png"&gt; &lt;/P&gt;
&lt;P&gt;In keeping with the VS Tradition, several files are created for you that have mildly annoying names like IService1, Service1, and some random namespace. Even though the names are a bit annoying, the project will compile and run as is.&lt;/P&gt;
&lt;P&gt;So, if one is giving this demo live, you could literally press F5, see the autohost and new WCF client start, and talk to those for as long as you felt compelled. I think the following points are important:&lt;/P&gt;
&lt;P&gt;1) the autohost is a dev-only thing. It is all about getting a feedback loop going. It's kindred spirits with Cassini.&lt;/P&gt;
&lt;P&gt;2) the autohost also lets you defer the choice of hosting. It may be the case that you aren't sure which host you will use. This autohost model helps you avoid (but doesn't prevent) you from creating frivolous dependencies on a type of host.&lt;/P&gt;
&lt;P&gt;3) the test client makes it easy to pass basic data back to the service and check the results. Again, this is about a feedback loop.&lt;/P&gt;
&lt;P&gt;4) The App.config created by the project creates 2 endpoints: a wsHttpBinding endpoint and a metadata exchange endpoint. It may be worth talking about how simple it is to setup endpoints that adhere to these complex protocols. It depends on the audience. Some of the more militant RESTafarian sects may well try to light your hair on fire if you bring up WS-*.&lt;/P&gt;
&lt;P&gt;5) You can change the config options using a new tool (WCFConfigEditor.exe). You get to that tool by right clicking the App.config file. This only works for the WCF Service library project. If you are trying to edit a config file in a project that was not created from that template, then you can go to the Tools menu, then select WCF Service Configuration Editor. After you do that, subsequet request for the context menu will work.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/justinjsmith/WindowsLiveWriter/LifeofaWCFDemoPart1_CDB6/img1_5.png" mce_href="http://blogs.msdn.com/blogfiles/justinjsmith/WindowsLiveWriter/LifeofaWCFDemoPart1_CDB6/img1_5.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=223 alt=img1 src="http://blogs.msdn.com/blogfiles/justinjsmith/WindowsLiveWriter/LifeofaWCFDemoPart1_CDB6/img1_thumb_1.png" width=244 border=0 mce_src="http://blogs.msdn.com/blogfiles/justinjsmith/WindowsLiveWriter/LifeofaWCFDemoPart1_CDB6/img1_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;In part 2, I will run through the code and config changes.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7202858" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Syndication/default.aspx">Syndication</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/JSON/default.aspx">JSON</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/_2600_quot_3B00_ASP.NET+AJAX+Integration_2600_quot_3B00_/default.aspx">&amp;quot;ASP.NET AJAX Integration&amp;quot;</category></item><item><title>PictureServices and BizTalk Services</title><link>http://blogs.msdn.com/justinjsmith/archive/2008/01/18/pictureservices-and-biztalk-services.aspx</link><pubDate>Sat, 19 Jan 2008 03:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7154978</guid><dc:creator>justinjsmith</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/7154978.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=7154978</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=7154978</wfw:comment><description>&lt;P&gt;Previous posts have talked a bit about PictureServices. Now I'd like to run through what it took to bring PictureServices to the BizTalk Services. I've talked a bit in other posts about BizTalk Services, but it has some interesting and very useful messaging features. For starters, BizTalk Services has an endpoint that can do HTTP transforms on messages. It goes like this:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;MyApp connects to BizTalk Services&lt;/LI&gt;
&lt;LI&gt;BizTalk Services and MyApp use WS-* security, coupled with the WCF binary message encoding.&lt;/LI&gt;
&lt;LI&gt;Other clients (Java, PHP, Ruby, whatever) can hit an HTTP endpoint hosted in the BizTalk Services "mesh". We will call this endpoint the HTTP Endpoint.&lt;/LI&gt;
&lt;LI&gt;Upon receipt of a message, the HTTP Endpoint tries to dispatch that message (or request) to MyApp.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;If we use this set of steps with PictureServices, then you have a way to serve local pictures over the internet. If you just look at this task, there are lots of other ways to do this. I'm not suggesting that BizTalk Services is the next cool way to share photos. Instead, I think there are lots of cool apps that can take advantage of this kind of feature set.&lt;/P&gt;
&lt;P&gt;Down to nuts and bolts - the service contract. PictureServices defines a service contract with operations for RSS, ATOM, and Simple list extensions. For the sake of time, I opted to have a single feature: get an RSS feed. Here's what the service contract looks like:&lt;/P&gt;&lt;PRE class=csharpcode&gt;[ServiceContract]
&lt;SPAN class=kwrd&gt;interface&lt;/SPAN&gt; IBTSPictureSyndication
{
  [OperationContract(Action=&lt;SPAN class=str&gt;"GET"&lt;/SPAN&gt;, ReplyAction=&lt;SPAN class=str&gt;"GETRESPONSE"&lt;/SPAN&gt;)]
  Message GetFeed();
}&lt;/PRE&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;/P&gt;
&lt;P&gt;The return type is System.ServiceModel.Channels.Message because the BizTalk Services SDK does not have full parity with the .NET Framework 3.5's capabilities. This will happen over time. To be honest, most of the head scratching I went through was due to the disparity between these two APIs.&lt;/P&gt;
&lt;P&gt;Another interesting bit is the implementation of the GetFeed method. The syndication, the images, and all the thumbnail HTTP GETs (remember they are transformed) are going to flow through this one method. As a result, we have to test the requested address to determine which resource is being requested. &lt;/P&gt;
&lt;P&gt;For that we turn to our new best friend: the UriTemplate. This is a new type introduced in .NET 3.5 - it makes URI parsing much easier (among other things).&lt;/P&gt;
&lt;P&gt;There are 3 conditions I test for: &lt;/P&gt;
&lt;P&gt;1) a request for the whole feed&lt;/P&gt;
&lt;P&gt;2) a request for an image&lt;/P&gt;
&lt;P&gt;3) a request for a thumbnail.&lt;/P&gt;
&lt;P&gt;Here's the implementation:&lt;/P&gt;&lt;PRE class=csharpcode&gt;[ServiceBehavior(AddressFilterMode=AddressFilterMode.Prefix)]
&lt;SPAN class=kwrd&gt;sealed&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; BTSPictureSyndication : IBTSPictureSyndication
{
    String feedUri = &lt;SPAN class=str&gt;"/Feed/"&lt;/SPAN&gt;;
    String pictureUri = &lt;SPAN class=str&gt;"/Feed/Picture/{pictureId}"&lt;/SPAN&gt;;
    String thumbnailUri = &lt;SPAN class=str&gt;"/Feed/Picture/t/{pictureId}"&lt;/SPAN&gt;;

    PictureService service = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; PictureService();

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; Message GetFeed()
    {
        &lt;SPAN class=rem&gt;// get the To address and the base address&lt;/SPAN&gt;
        Uri to = OperationContext.Current.RequestContext.RequestMessage.Headers.To;
        Uri baseAddress = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Uri(ConfigurationManager.AppSettings[&lt;SPAN class=str&gt;"baseAddress"&lt;/SPAN&gt;]);

        &lt;SPAN class=rem&gt;// check to see if it's a request for the main feed&lt;/SPAN&gt;
        UriTemplate feedTemplate = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; UriTemplate(feedUri);
        UriTemplateMatch feedMatch = feedTemplate.Match(baseAddress, to);

        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (feedMatch != &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;)
        {
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; GetMainFeed();
        }

        &lt;SPAN class=rem&gt;// check to see if it's a request for a picture&lt;/SPAN&gt;
        UriTemplate pictureTemplate = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; UriTemplate(pictureUri);
        UriTemplateMatch pictureMatch = pictureTemplate.Match(baseAddress, to);

        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (pictureMatch != &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;)
        {
            String pictureId = pictureMatch.BoundVariables[&lt;SPAN class=str&gt;"pictureId"&lt;/SPAN&gt;];
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; GetPicture(pictureId);
        }

        &lt;SPAN class=rem&gt;// check to see if it's a request for a thumbnail&lt;/SPAN&gt;
        UriTemplate thumbnailTemplate = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; UriTemplate(thumbnailUri);
        UriTemplateMatch thumbnailMatch = thumbnailTemplate.Match(baseAddress, to);

        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (thumbnailMatch != &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;)
        {
            String pictureId = thumbnailMatch.BoundVariables[&lt;SPAN class=str&gt;"pictureId"&lt;/SPAN&gt;];
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; GetPictureThumbnail(pictureId);
        }

        &lt;SPAN class=rem&gt;// we don't know what it is, so throw&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;throw&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; InvalidOperationException(String.Format(&lt;SPAN class=str&gt;"the address {0} was not matched"&lt;/SPAN&gt;, to.ToString()));

    }

    &lt;SPAN class=rem&gt;// use the service object to get the picture&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; Message GetPicture(String pictureId)
    {
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; StreamMessageHelper.CreateMessage(OperationContext.Current.IncomingMessageVersion, &lt;/PRE&gt;&lt;PRE class=csharpcode&gt;        &lt;SPAN class=str&gt;"GETRESPONSE"&lt;/SPAN&gt;, service.GetPicture(pictureId));
    }

    &lt;SPAN class=rem&gt;// use the service object to get a thumbnail&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; Message GetPictureThumbnail(String pictureId)
    {
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; StreamMessageHelper.CreateMessage(OperationContext.Current.IncomingMessageVersion, &lt;/PRE&gt;&lt;PRE class=csharpcode&gt;        &lt;SPAN class=str&gt;"GETRESPONSE"&lt;/SPAN&gt;, service.GetPictureThumbnail(pictureId));
    }

    &lt;SPAN class=rem&gt;// get the main feed (RSS)&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; Message GetMainFeed()
    {
        Rss20FeedFormatter formatter = service.GetPicturesAsRss();

        MemoryStream stream = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; MemoryStream();
        XmlWriter writer = XmlWriter.Create(stream);

        formatter.WriteTo(writer);

        writer.Close();
        stream.Position = 0;

        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; StreamMessageHelper.CreateMessage(OperationContext.Current.IncomingMessageVersion, &lt;SPAN class=str&gt;"GETRESPONSE"&lt;/SPAN&gt;, stream);
    }
}&lt;/PRE&gt;
&lt;P&gt;Another thing that's worth pointing out is the presence of the AddressFilterMode property on the ServiceBehavior attribute annotation. This setting tells the WCF dispatching infrastructure to allow prefix matches to filter through to the method. In practical terms, this means that a request to &lt;A href="http://foo/bar/baz" mce_href="http://foo/bar/baz"&gt;http://foo/bar/baz&lt;/A&gt; would get dispatched to the same method as &lt;A href="http://foo/bar" mce_href="http://foo/bar"&gt;http://foo/bar&lt;/A&gt;. That's how we are returning the full feed, the image, or a thumbnail.&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://netfx3.com/files/folders/wcf_samples/entry15417.aspx" target=_blank mce_href="http://netfx3.com/files/folders/wcf_samples/entry15417.aspx"&gt;Here's a zipped version of the project &lt;/A&gt;(note that you must also have PictureServices).&lt;/P&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7154978" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Syndication/default.aspx">Syndication</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Services+in+the+Cloud/default.aspx">Services in the Cloud</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/BizTalk+Services/default.aspx">BizTalk Services</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/BizTalk.NET+Services/default.aspx">BizTalk.NET Services</category></item><item><title>XML namespace declarations in SyndicationFeed objects</title><link>http://blogs.msdn.com/justinjsmith/archive/2008/01/16/xml-namespace-declarations-in-syndicationfeed-objects.aspx</link><pubDate>Wed, 16 Jan 2008 12:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7128380</guid><dc:creator>justinjsmith</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/7128380.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=7128380</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=7128380</wfw:comment><description>&lt;P&gt;Following on the heels of &lt;A href="http://hyperthink.net/blog/2008/01/15/Declaring+XML+Namespaces+On+A+SyndicationFeed.aspx" mce_href="http://hyperthink.net/blog/2008/01/15/Declaring+XML+Namespaces+On+A+SyndicationFeed.aspx"&gt;Steve Maine's post&lt;/A&gt; about namespaces in Syndication objects (Feeds, items, etc.), I thought it wise to plug the new stuff in &lt;A href="http://samples.netfx3.com/pictureservices" mce_href="http://samples.netfx3.com/pictureservices"&gt;PictureServices&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;At the moment, &lt;A href="http://samples.netfx3.com/pictureservices" mce_href="http://samples.netfx3.com/pictureservices"&gt;PictureServices&lt;/A&gt; implements SLE (Simple List Extensions), and does a pretty crude job of it at that. Time permitting, I will add more support for field and group customization. For now, it serves as an example more than a carrier grade implementation. In any event, I used extension methods in the following type definition to make it easy to insert the right namespace declarations in the feed:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Collections.Generic;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Linq;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Text;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.ServiceModel.Syndication;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Xml;

&lt;SPAN class=kwrd&gt;namespace&lt;/SPAN&gt; Microsoft.DPE.Samples.SyndicationExtensions
{
    &lt;SPAN class=rem&gt;// adds custom namespaces to an item or a feed&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; SyndicationNamespaceHelper
    {
        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; DeclareNamespace(&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt; SyndicationFeed feed, &lt;BR&gt;                                                 String prefix,&lt;BR&gt;                                                 String ns)
        {
            XmlQualifiedName key = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; XmlQualifiedName(prefix, NamespaceUris.XMLNamespace);
            feed.AttributeExtensions.Add(key, ns);
        }

        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; DeclareNamespace(&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt; SyndicationItem item, &lt;BR&gt;                                                 String prefix,&lt;BR&gt;                                                 String ns)
        {
            XmlQualifiedName key = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; XmlQualifiedName(prefix, NamespaceUris.XMLNamespace);
            item.AttributeExtensions.Add(key, ns);
        }
    }
}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;The usage model is simple - just new up a feed or an item, then call DeclareNamespace. Piece of cake.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7128380" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Syndication/default.aspx">Syndication</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category></item><item><title>PictureServices updated to VS 2008 RTM</title><link>http://blogs.msdn.com/justinjsmith/archive/2008/01/14/pictureservices-updated-to-vs-2008-rtm.aspx</link><pubDate>Tue, 15 Jan 2008 06:18:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7114971</guid><dc:creator>justinjsmith</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/7114971.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=7114971</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=7114971</wfw:comment><description>&lt;p&gt;Today I updated PictureServices to work with the RTM release of Visual Studio 2008 and the .NET Framework 3.5 (what a mouthful). My testing rigor for this release was less than perfect. Please let me know if you find any bugs.&lt;/p&gt;  &lt;p&gt;For what it's worth, the changes in the API made the simple list extensions implementation simpler. Honestly, I was skeptical at first, but it really is pretty straightforward. &lt;/p&gt;  &lt;p&gt;Check out the new version &lt;a href="http://samples.netfx3.com/pictureservices"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7114971" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Syndication/default.aspx">Syndication</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category></item><item><title>PictureServices status update</title><link>http://blogs.msdn.com/justinjsmith/archive/2008/01/14/pictureservices-status-update.aspx</link><pubDate>Mon, 14 Jan 2008 20:13:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7109720</guid><dc:creator>justinjsmith</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/7109720.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=7109720</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=7109720</wfw:comment><description>I've received several mails about PictureServices and RTM. As some of you know, the Syndication API changed before RTM. The were subtle, but they did have an impact on the Picture Services project. Specifically, the simple list extensions part of Picture Services isn't up to date with the RTM bits. I will update the bits this week and repost...&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7109720" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category></item><item><title>WCF Syndication article in MSDN Magazine...</title><link>http://blogs.msdn.com/justinjsmith/archive/2007/12/23/wcf-syndication-article-in-msdn-magazine.aspx</link><pubDate>Sun, 23 Dec 2007 17:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6845637</guid><dc:creator>justinjsmith</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/6845637.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=6845637</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=6845637</wfw:comment><description>&lt;P&gt;It seems that the RSS/Atom article I wrote for MSDN magazine was just published: &lt;A href="http://msdn.microsoft.com/msdnmag/issues/08/01/WCFinOrcas/default.aspx" mce_href="http://msdn.microsoft.com/msdnmag/issues/08/01/WCFinOrcas/default.aspx"&gt;http://msdn.microsoft.com/msdnmag/issues/08/01/WCFinOrcas/default.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The RTM version of .NET 3.5 was not available when I wrote the article, so I avoided the extensibility capabilites of the API. Perhaps that's fodder for another article.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6845637" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Syndication/default.aspx">Syndication</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category></item><item><title>Setting HTTP Headers in WCF (.NET 3.5)</title><link>http://blogs.msdn.com/justinjsmith/archive/2007/08/22/setting-http-headers-in-wcf-net-3-5.aspx</link><pubDate>Wed, 22 Aug 2007 20:41:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4513672</guid><dc:creator>justinjsmith</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/4513672.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=4513672</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=4513672</wfw:comment><description>&lt;p&gt;One of the cool parts of WCF in the .NET 3.5 is the simplified support of the REST architectural style. URIs, HTTP verbs, and HTTP headers are 1st class citizens in the programming model. Each of these citizens is interesting. I'll focus a bit on HTTP headers here.&lt;/p&gt; &lt;p&gt;HTTP headers dictate a wide array of characteristics of how a server responds to a request and how a client reacts to the response sent by the server. A full discussion is beyond the scope of my blog post, but this stuff has been around for quite a while. You should be able to do&amp;nbsp;a Live Search on HTTP Headers to dig up more info on their uses.&lt;/p&gt; &lt;p&gt;There's two uses that are particularly interesting from a services perspective: &lt;strong&gt;Content-Type and Cache-Control&lt;/strong&gt;. &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Content-Type&lt;/strong&gt; serves as a way for the server to indicate the data format and is expressed as a MIME type label. SOAP / WS-*&amp;nbsp;services generally express data format in terms of schema and WSDL. Schema and WSDL are highly expressive, whereas Content-Type is dramatically simpler. The web tends to rely on Content-Type.&lt;/p&gt; &lt;p&gt;The &lt;strong&gt;Cache-Control&lt;/strong&gt; response header indicates how long a response is valid. It also can include instructions regarding how the client should validate their cache. You can get the particulars straight from the horses mouth: &lt;a title="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html"&gt;http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The easiest way to set the value of these headers in a WCF application is via the WebOperationContext type. An object of this type is normally available in a method of a service object, and follows the usage pattern demonstrated in .NET 3.0's OperationContext type.&lt;/p&gt; &lt;p&gt;Here's how you can set he Content-Type header in a method of a service object (for the HTTP wonks, I've omitted charset):&lt;/p&gt; &lt;p&gt; &lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:204a7b6f-bd82-40f8-aa6a-14e4a1575de4" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080; "&gt;1&lt;/span&gt; &lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;public&lt;/span&gt;&lt;span style="color: #000000; "&gt; String SomeMethod(Int32 someNumber) {
&lt;/span&gt;&lt;span style="color: #008080; "&gt;2&lt;/span&gt; &lt;span style="color: #000000; "&gt;  &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; normal implementation would go here
&lt;/span&gt;&lt;span style="color: #008080; "&gt;3&lt;/span&gt; &lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;4&lt;/span&gt; &lt;span style="color: #008000; "&gt;  &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; set the Content-Type&lt;/span&gt;&lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;5&lt;/span&gt; &lt;span style="color: #008000; "&gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt;  WebOperationContext.Current.OutgoingResponse.ContentType &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;text/html&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;6&lt;/span&gt; &lt;span style="color: #000000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;7&lt;/span&gt; &lt;span style="color: #000000; "&gt;  &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; return something&lt;/span&gt;&lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;8&lt;/span&gt; &lt;span style="color: #008000; "&gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt;  &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;return&lt;/span&gt;&lt;span style="color: #000000; "&gt; someNumber.ToString();
&lt;/span&gt;&lt;span style="color: #008080; "&gt;9&lt;/span&gt; &lt;span style="color: #000000; "&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Here's how you could set the Cache-Control response header and the validation HTTP headers:
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:afbb44d0-6826-452b-bba9-b437a2836ff7" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #008080; "&gt; 1&lt;/span&gt; &lt;span style="color: #0000FF; "&gt;public&lt;/span&gt;&lt;span style="color: #000000; "&gt; String SomeMethod(Int32 someNumber) {
&lt;/span&gt;&lt;span style="color: #008080; "&gt; 2&lt;/span&gt; &lt;span style="color: #000000; "&gt;    
&lt;/span&gt;&lt;span style="color: #008080; "&gt; 3&lt;/span&gt; &lt;span style="color: #000000; "&gt;    &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; normal implementation would go here
&lt;/span&gt;&lt;span style="color: #008080; "&gt; 4&lt;/span&gt; &lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt; 5&lt;/span&gt; &lt;span style="color: #008000; "&gt;    &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; set the Content-Type&lt;/span&gt;&lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt; 6&lt;/span&gt; &lt;span style="color: #008000; "&gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt;    WebOperationContext.Current.OutgoingResponse.ContentType &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;text/html&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;;
&lt;/span&gt;&lt;span style="color: #008080; "&gt; 7&lt;/span&gt; &lt;span style="color: #000000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt; 8&lt;/span&gt; &lt;span style="color: #000000; "&gt;    &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; call a helper method that sets cache-control header&lt;/span&gt;&lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt; 9&lt;/span&gt; &lt;span style="color: #008000; "&gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt;    SetCaching(WebOperationContext.Current, DateTime.Now, &lt;/span&gt;&lt;span style="color: #000000; "&gt;120&lt;/span&gt;&lt;span style="color: #000000; "&gt;);
&lt;/span&gt;&lt;span style="color: #008080; "&gt;10&lt;/span&gt; &lt;span style="color: #000000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;11&lt;/span&gt; &lt;span style="color: #000000; "&gt;    &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; return something&lt;/span&gt;&lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;12&lt;/span&gt; &lt;span style="color: #008000; "&gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt;    &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;return&lt;/span&gt;&lt;span style="color: #000000; "&gt; someNumber.ToString();
&lt;/span&gt;&lt;span style="color: #008080; "&gt;13&lt;/span&gt; &lt;span style="color: #000000; "&gt;}
&lt;/span&gt;&lt;span style="color: #008080; "&gt;14&lt;/span&gt; &lt;span style="color: #000000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;15&lt;/span&gt; &lt;span style="color: #000000; "&gt;&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;private&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;void&lt;/span&gt;&lt;span style="color: #000000; "&gt; SetCaching(WebOperationContext context, DateTime lastModifiedDate, Int32 maxCacheAge){
&lt;/span&gt;&lt;span style="color: #008080; "&gt;16&lt;/span&gt; &lt;span style="color: #000000; "&gt;    
&lt;/span&gt;&lt;span style="color: #008080; "&gt;17&lt;/span&gt; &lt;span style="color: #000000; "&gt;    &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; set CacheControl header&lt;/span&gt;&lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;18&lt;/span&gt; &lt;span style="color: #008000; "&gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt;    HttpResponseHeader cacheHeader &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; HttpResponseHeader.CacheControl;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;19&lt;/span&gt; &lt;span style="color: #000000; "&gt;    String cacheControlValue &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; String.Format(&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;max-age={0}, must-revalidate&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;, maxCacheAge);
&lt;/span&gt;&lt;span style="color: #008080; "&gt;20&lt;/span&gt; &lt;span style="color: #000000; "&gt;    context.OutgoingResponse.Headers.Add(cacheHeader, cacheControlValue);
&lt;/span&gt;&lt;span style="color: #008080; "&gt;21&lt;/span&gt; &lt;span style="color: #000000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;22&lt;/span&gt; &lt;span style="color: #000000; "&gt;    &lt;/span&gt;&lt;span style="color: #008000; "&gt;//&lt;/span&gt;&lt;span style="color: #008000; "&gt; set cache validation &lt;/span&gt;&lt;span style="color: #008000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;23&lt;/span&gt; &lt;span style="color: #008000; "&gt;&lt;/span&gt;&lt;span style="color: #000000; "&gt;    context.OutgoingResponse.LastModified &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; lastModifiedDate;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;24&lt;/span&gt; &lt;span style="color: #000000; "&gt;    String eTag &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; context.IncomingRequest.UriTemplateMatch.RequestUri.ToString() &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; lastModifiedDate.ToString();
&lt;/span&gt;&lt;span style="color: #008080; "&gt;25&lt;/span&gt; &lt;span style="color: #000000; "&gt;    context.OutgoingResponse.ETag &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; eTag;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;26&lt;/span&gt; &lt;span style="color: #000000; "&gt;
&lt;/span&gt;&lt;span style="color: #008080; "&gt;27&lt;/span&gt; &lt;span style="color: #000000; "&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;There are lots of different options available for caching and validation. If there's interest, I will dive into those in a future post. It's hard to gauge what's common knowledge about these headers.&lt;/p&gt;
&lt;p&gt;From a debugging perspective, know that &lt;a href="http://www.fiddlertool.com/Fiddler/version.asp"&gt;Fiddler&lt;/a&gt; is your best friend. When you are watching headers on localhost services, you won't see the sessions in Fiddler unless you use the full machine name in the request. The machine name forces the request to go through the fiddler proxy.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4513672" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category></item><item><title>Check out Picture Services</title><link>http://blogs.msdn.com/justinjsmith/archive/2007/08/20/check-out-picture-services.aspx</link><pubDate>Tue, 21 Aug 2007 01:23:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4485395</guid><dc:creator>justinjsmith</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/4485395.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=4485395</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=4485395</wfw:comment><description>&lt;p&gt;A few days ago we released a new sample called Picture Services. As the name implies, this sample centers on pictures. More specifically, it demonstrates how to use the WCF API in the .NET Framework 3.5 to syndicate images from your local machine and expose them via a REST endpoint. &lt;/p&gt; &lt;p&gt;There's been a fair amount of buzz&amp;nbsp;recently&amp;nbsp;around REST development. With the .NET Framework 3.5, REST constructs are now 1st class citizens in the WCF programming model.&lt;/p&gt; &lt;p&gt;We've tried to make the sample easy to understand, but still have enough complexity to warrant investigation. Features highlighted include: simple syndication, Simple List Extensions, HTTP GET programming, as well as some of the new tooling and hosting options. Check it out and let me know what you think.&lt;/p&gt; &lt;p&gt;To download the sample, just go &lt;a href="http://samples.netfx3.com/pictureservices/"&gt;here&lt;/a&gt;, select "Source Code", and then "Download". Alternately, you can simply go &lt;a href="http://www.netfx3.com/files/folders/sampleservices/entry11931.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4485395" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Syndication/default.aspx">Syndication</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category></item><item><title>ASP.NET, WCF, and Asynchronous Programming</title><link>http://blogs.msdn.com/justinjsmith/archive/2007/08/01/asp-net-wcf-and-asynchronous-programming.aspx</link><pubDate>Thu, 02 Aug 2007 00:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4176604</guid><dc:creator>justinjsmith</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/4176604.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=4176604</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=4176604</wfw:comment><description>&lt;P&gt;Jeffrey Richter told me once that a CPU was a terrible thing to waste. I don't know if he was the one to coin the term - in fact, I think he told me someone else coined that term. Regardless of where it came from, the principle behind that phrase is solid. All too often, developers do I/O synchronously, thereby wasting CPU time, and making their applications less scalable and responsive. Terrible.&lt;/P&gt;
&lt;P&gt;Often the excuse is that one expects the I/O to happen quickly. One seldom (if ever) can predict how fast any I/O is going to take, so this is a non-starter. Never do synchronous I/O. Never ever. Read Jeff Richter's CLR Via C# for an eloquent explanation of why.&lt;/P&gt;
&lt;P&gt;This premise surfaces in WCF programming from within an ASP.NET application. Consider this scenario:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;A Page_Load event handler needs to send a message to a web service and do something with the result. &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Simply put, the ASP.NET application needs to do I/O. If the web service call is synchronous, the thread that is executing the Page_Load event (and the web service call) blocks until the web service call returns. That thread cannot be used to process other requests while waiting, and the web server will soon return 503 errors.&amp;nbsp;Since the web service call takes a long time (try not to quibble that it is usually fast), you are wasting threads and CPU time. Terrible.&lt;/P&gt;
&lt;P&gt;If, however, you use ASP.NET Async pages and an asynchronous call to the web service, you are not wasting the CPU. Very good. For more info on the async capabilities of ASP.NET 2.0, see Jeff Prosise's most excellent article: &lt;A title=http://msdn.microsoft.com/msdnmag/issues/05/10/WickedCode/ href="http://msdn.microsoft.com/msdnmag/issues/05/10/WickedCode/" mce_href="http://msdn.microsoft.com/msdnmag/issues/05/10/WickedCode/"&gt;http://msdn.microsoft.com/msdnmag/issues/05/10/WickedCode/&lt;/A&gt;. With WCF, you would do something like:&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:6db1861f-0b27-4324-91e3-bc2310b6de34 contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: #008080"&gt; 1&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;partial&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _Default : System.Web.UI.Page 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 2&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;{
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 3&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    IService1 proxy;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 4&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    ChannelFactory&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;IService1&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; factory;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 5&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 6&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Page_Load(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; sender, EventArgs e)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 7&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    {
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 8&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        WSHttpBinding binding &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; WSHttpBinding();
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 9&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        EndpointAddress address &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; EndpointAddress(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;http://localhost:8080/Service1&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;10&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;11&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; you could also reuse a proxy...&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;12&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        factory &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ChannelFactory&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;IService1&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(binding, address);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;13&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;14&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.AddOnPreRenderCompleteAsync(
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;15&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; BeginEventHandler(BeginAsyncOperation),
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;16&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; EndEventHandler(EndAsyncOperation)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;17&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        );
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;18&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;19&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;20&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;21&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    IAsyncResult BeginAsyncOperation(Object sender, EventArgs e,
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;22&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        AsyncCallback cb, Object state)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;23&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    {
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;24&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        proxy &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; factory.CreateChannel();
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;25&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; proxy.BeginGetData(TextBox1.Text, cb, state);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;26&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;27&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;28&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; EndAsyncOperation(IAsyncResult ar)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;29&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    {
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;30&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        String output &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; proxy.EndGetData(ar);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;31&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        Label2.Text &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; output;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;32&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;33&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Line 24 is where is I/O starts. BeginGetData returns an IAsyncResult and the thread goes into back into the thread pool. When the result comes back, the EndAsyncOperation method is called, and the proxy's end method can be called.&lt;/P&gt;
&lt;P&gt;The model isn't hard, and it greatly improves the scalability of your ASP.NET application. On top of that, it doesn't waste the CPU...&lt;/P&gt;
&lt;P&gt;The full code sample is here&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4176604" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/justinjsmith/attachment/4176604.ashx" length="10583" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category></item><item><title>WCF, ASP.NET AJAX, and JavaScript Proxies</title><link>http://blogs.msdn.com/justinjsmith/archive/2007/07/23/wcf-asp-net-ajax-and-javascript-proxies.aspx</link><pubDate>Tue, 24 Jul 2007 07:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4021518</guid><dc:creator>justinjsmith</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/4021518.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=4021518</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=4021518</wfw:comment><description>&lt;P&gt;I spent this weekend tinkering around with the JSON messaging capabilities of WCF new in the .NET Framework 3.5 (Orcas). The object model is changing substantially between Beta1 and Beta2, and I think the changes make for an easier to use system.&lt;/P&gt;
&lt;P&gt;To better understand the JSON messaging features of WCF, check out some of the general requirements they were built to:&lt;/P&gt;
&lt;P&gt;1) Config-free deployment for JSON endpoints&lt;/P&gt;
&lt;P&gt;2) ASP.NET AJAX developer experience consistent with ASMX endpoints&lt;/P&gt;
&lt;P&gt;3) Give service developers the same WCF developer experience as WCF v1&lt;/P&gt;
&lt;P&gt;I am sure there were more, but these were the big ones related to developer experience.&lt;/P&gt;
&lt;P&gt;Now, lets look at some code. A good place to start is the contract.&lt;/P&gt;
&lt;H3&gt;The Service&amp;nbsp;Contract&lt;/H3&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2e6aa3e9-cad1-4bf3-8bc2-eacf16ad5ca3 contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: #000000"&gt;[ServiceContract]
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;interface&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; IWCFAjaxService {
    [OperationContract]
    [WebInvoke(Method &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;POST&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, UriTemplate &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;ShowServerDate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)]
    String ShowServerDate();
}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;The only thing that is different in this contract from a WCF contract from WCF v1 is the presence of the WebInvoke attribute. Simply put (almost pun intended), this attribute indicates that the operation will be accessible via the HTTP verb indicated by the Method instance property. In this case, the HTTP verb is POST.&lt;/P&gt;
&lt;H4&gt;The Service Type&lt;/H4&gt;
&lt;P&gt;This is pretty straightforward, so I'll just show it for completeness:&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ece75418-9fbe-48c4-9fae-ddb454942fda contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; WCFAjaxService : IWCFAjaxService {
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ShowServerDate()    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; DateTime.Now.ToString();
    }
}
&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;H4&gt;The SVC file&lt;/H4&gt;
&lt;P&gt;SVC files are an activation target for WCF services hosted in IIS. Since this example is showing a web page that calls a WCF service, IIS is the natural host.&amp;nbsp;The svc file is simple:&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:5ff3a33e-a12e-4e44-9145-c06e9b8c55b5 contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white; WORD-WRAP: break-word"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;@ ServiceHost Language&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;C#&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; Debug&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; Service&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;WCFAjaxService&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; Factory&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;System.ServiceModel.Activation.WebScriptServiceHostFactory&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Notice the presence of the Factory part of the directive. This indicates that the ServiceHostFactory to be used is the WebScriptServiceHostFactory. This is a new type that ships with .NET Framework 3.5.&amp;nbsp;It creates a ServiceHost that has the right endpoint (behaviors, binding, etc) that will work for AJAX integration.&lt;/P&gt;
&lt;H4&gt;The ASPX file&lt;/H4&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c72788c3-043d-4a04-a1c9-5d8aa669eee4 contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: #008080"&gt; 1&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;@ Page Language&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;C#&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; AutoEventWireup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; CodeFile&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;Default.aspx.cs&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; Inherits&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;_Default&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 2&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 3&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;!&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff00ff"&gt;DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 4&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff00ff"&gt;                    Transitional//EN" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 5&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff00ff"&gt;                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 6&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;html &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 7&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;head &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Head1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 8&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;WCF Ajax Demo&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt; 9&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;10&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;script &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="text/javascript"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;11&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;    
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;12&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;      &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; GetServerTime(){
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;13&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; proxy &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; tempuri.org.IWCFAjaxService();
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;14&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;        proxy.ShowServerDate(OnSucceeded, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;15&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;      }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;16&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;  
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;17&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;      &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; OnSucceeded(result)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;18&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;      {
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;19&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; RsltElem &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; document.getElementById(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;Results&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;20&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;        RsltElem.innerHTML &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt; result;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;21&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;      }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;22&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;    
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;23&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;script&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;24&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;25&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;head&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;26&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;27&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;form &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="form1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;28&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;29&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;asp:ScriptManager &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="scriptManager"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;30&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;Services&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;31&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;asp:ServiceReference &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;Path&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="~/Service.svc"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;32&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;Services&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;33&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;asp:ScriptManager&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;34&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;h2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;35&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;            Server Time&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;h2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;36&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;p&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;37&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;            Calling a service that returns the current server time.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;p&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;38&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;input &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="DateButton"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="button"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="GetTime"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;39&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;                   onclick&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="GetServerTime()"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;40&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;41&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;42&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;br &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;43&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;span &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Results"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;span&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;44&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;45&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;form&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;46&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;47&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;html&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;48&lt;/SPAN&gt; &lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;The important parts of this code snippet are lines 29-33 (ScriptManager) and lines 12-15 (proxy call). In you are new to AJAX development, I encourage you to visit &lt;A href="http://www.asp.net/" mce_href="http://www.asp.net"&gt;http://www.asp.net&lt;/A&gt; for more info. 
&lt;P&gt;The ScriptManager is the main integration point for web services and ASP.NET AJAX. Adding a Service node in the Services collection will create a JavaScript proxy, and you can all that JavaScript proxy from other functions in your page.&lt;/P&gt;
&lt;H4&gt;See the JavaScript Proxy&lt;/H4&gt;
&lt;P&gt;When I first tackled this, I could not get the proxy to generate, and I could not seem to find out the name of the proxy. The trick is to navigate to the svc url, then add a JS to the URL.&lt;/P&gt;
&lt;P&gt;If your starting URL is &lt;A href="http://localhost/WCFAjaxService/Service.svc" mce_href="http://localhost/WCFAjaxService/Service.svc"&gt;http://localhost/WCFAjaxService/Service.svc&lt;/A&gt;, then the JavaScript proxy URL is &lt;A href="http://localhost/WCFAjaxService/Service.svc/js" mce_href="http://localhost/WCFAjaxService/Service.svc/js"&gt;http://localhost/WCFAjaxService/Service.svc/js&lt;/A&gt;. When you download that file, you'll see that the name of the proxy follows the naming convention of your service contract's XML namespace (hence tempuri.org in lines 12-15)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The complete sample is below.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4021518" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/justinjsmith/attachment/4021518.ashx" length="4352" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/JSON/default.aspx">JSON</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/ASP.NET+AJAX/default.aspx">ASP.NET AJAX</category></item><item><title>Syndication formats, endpoints and config files</title><link>http://blogs.msdn.com/justinjsmith/archive/2007/07/18/syndication-formats-endpoints-and-config-files.aspx</link><pubDate>Wed, 18 Jul 2007 20:54:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3940532</guid><dc:creator>justinjsmith</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/3940532.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=3940532</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=3940532</wfw:comment><description>&lt;p&gt;I got a question via email today that forced me to look back through some older emails for the answer. It may make sense to share the question / answer in a broader sense. &lt;/p&gt; &lt;p&gt;Earlier builds of Orcas surfaced a syndication format to an endpoint by way of a behavior. In essence, you could add a SyndicationBehavior to an endpoint, and that behavior dictated the syndication format for that endpoint (RSS or ATOM). With this model you can specify the syndication format in a config file.&lt;/p&gt; &lt;p&gt;The endpoint centric model for syndication formats is no longer in place. The current model centers on the return type for the operation that returns the syndication. If you want to return a syndication from an operation, you should return a SyndicationFeedFormatter&amp;lt;T&amp;gt; or one of it's derived types (RSS and ATOM types available). In the current incarnation, this removes the config options for syndication formats, but the benefit is worth it (in my opinion).&lt;/p&gt; &lt;p&gt;The motivation for this change (according to Steve Maine) has to do with the embrace of the URI in web-centric programming. Strapping an endpoint to a particular format has undesirable impacts on the URI structures of the service(s). Many customers wanted to serve RSS or ATOM from one URI, and vary the format based on the presence of a query string or an accept header. As a result, the SyndicationBehavior vanished.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3940532" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Syndication/default.aspx">Syndication</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas+Beta+1/default.aspx">Orcas Beta 1</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category></item><item><title>IBM MQ Custom Channel</title><link>http://blogs.msdn.com/justinjsmith/archive/2007/07/16/ibm-mq-custom-channel.aspx</link><pubDate>Mon, 16 Jul 2007 21:25:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3899531</guid><dc:creator>justinjsmith</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/3899531.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=3899531</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=3899531</wfw:comment><description>&lt;p&gt;I just saw a mail introducing an alpha release from IBM - an MQ series custom channel. It appears to be early stage, so don't throw this into production yet.&lt;/p&gt; &lt;p&gt;Several have asked me if it's possible to connect WCF to MQ - my answer is yes, but it requires a fair amount of custom code. If this channel makes it to a full-fledged release from IBM, you won't even have to do that.&lt;/p&gt; &lt;p&gt;Here's the link: &lt;a title="http://www.alphaworks.ibm.com/tech/mqwcf/" href="http://www.alphaworks.ibm.com/tech/mqwcf/"&gt;http://www.alphaworks.ibm.com/tech/mqwcf/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3899531" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category></item><item><title>WebServiceHost vs ServiceHost</title><link>http://blogs.msdn.com/justinjsmith/archive/2007/07/02/webservicehost-vs-servicehost.aspx</link><pubDate>Mon, 02 Jul 2007 21:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3662687</guid><dc:creator>justinjsmith</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/justinjsmith/comments/3662687.aspx</comments><wfw:commentRss>http://blogs.msdn.com/justinjsmith/commentrss.aspx?PostID=3662687</wfw:commentRss><wfw:comment>http://blogs.msdn.com/justinjsmith/rsscomments.aspx?PostID=3662687</wfw:comment><description>&lt;P&gt;WCF in .NET Fx 3.5 introduces several types that simplify the creation of services that use the protocols of the web (read REST/Syndication/JSON). Among these are two hosting types: WebServiceHost and WebScriptServiceHostFactory. These types serve the same function as the ServiceHost and ServiceHostFactory type, but they are tailored for the web. For example, WebServiceHost automatically adds the right behavior and does some error checking to ensure http is the transport. Likewise, the WebScriptServiceHostFactory does similar error checking and adds a behavior that sets up the JSON messaging stack. &lt;/P&gt;
&lt;P&gt;The WebScriptServiceHostFactory means that developers can setup an .svc file with no config (via directives), and the WebServiceHost means that web developers do not have to muck about with WCF behaviors.&lt;/P&gt;
&lt;P&gt;These types automate with work one would otherwise have to do with the ServiceHost type. If, for some reason, you do not want to or cannot use these new types, you can always use the ServiceHost. &lt;/P&gt;
&lt;P&gt;The code below shows how to expose a REST endpoint with both the ServiceHost and the WebServiceHost types:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;sealed&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; Program : ISomeContract {

    &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Main(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;[] args) {
        
        Uri baseAddress = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Uri(&lt;SPAN class=str&gt;"http://localhost:8000"&lt;/SPAN&gt;);

        HostWithServiceHost(baseAddress);

        HostWithWebServiceHost(baseAddress);
    }

    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; HostWithServiceHost(Uri baseAddress) {
        
        ServiceHost host = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ServiceHost(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(Program), baseAddress);
        WebHttpBinding binding = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebHttpBinding();

        ServiceEndpoint endpoint = host.AddServiceEndpoint(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(ISomeContract), binding, &lt;SPAN class=str&gt;"ServiceHost"&lt;/SPAN&gt;);
        WebHttpBehavior httpBehavior = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebHttpBehavior();
        endpoint.Behaviors.Add(httpBehavior);

        host.Open();

        Console.WriteLine(&lt;SPAN class=str&gt;@"go to http://localhost:8000/ServiceHost/SomeOperation to test"&lt;/SPAN&gt;);
        Console.ReadLine();

    }

    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; HostWithWebServiceHost(Uri baseAddress) {
        
        WebServiceHost host = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebServiceHost(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(Program), baseAddress);
        WebHttpBinding binding = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebHttpBinding();
        host.AddServiceEndpoint(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(ISomeContract), binding, &lt;SPAN class=str&gt;"WebServiceHost"&lt;/SPAN&gt;);
        host.Open();

        Console.WriteLine(&lt;SPAN class=str&gt;@"go to http://localhost:8000/WebServiceHost/SomeOperation to test"&lt;/SPAN&gt;);
        Console.ReadLine();
        host.Close();
    
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; String SomeOperation(String input) {
    
        String reply = &lt;SPAN class=str&gt;"You said: "&lt;/SPAN&gt; + input;
        Console.WriteLine(reply);
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; reply;
    
    }
}

[ServiceContract]
&lt;SPAN class=kwrd&gt;interface&lt;/SPAN&gt; ISomeContract {
    [OperationContract]
    [WebGet(UriTemplate=&lt;SPAN class=str&gt;"SomeOperation/{input}"&lt;/SPAN&gt;)]
    String SomeOperation(String input);
}

&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3662687" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/REST/default.aspx">REST</category><category domain="http://blogs.msdn.com/justinjsmith/archive/tags/Web+Programming+with+WCF/default.aspx">Web Programming with WCF</category></item></channel></rss>