Monday, May 12, 2008

In case you haven't noticed yet, the bits for .NET 3.5 SP1 Beta 1 and Visual Studio 2008  SP1 Beta 1 are now available...take a minute and go grab them, and then you can finish reading this post while they install :)

What's new?
Looking at the platform holistically, the big-ticket features in SP1 are the ADO.NET Entity Framework (finally ;) ) and the ADO.NET Data Services (Astoria). I'm sure lots of folks will be talking in-depth about those things, so I'll focus on some of the smaller (but no less interesting!) features that my team is delivering as part of this release.

From the WCF/WF perspective, here's what you can look for in SP1. There's a lot here and each one of these probably merits an individual post but here are the bullet points:

Core Framework

  • Expanded UriTemplate syntax including support for compound template segments (like /{filename}.{ext} and /customers({id})), default values (like /customers/{id=0}), and optional trailing slashes.
  • Syndication OM for the Atom Publishing Protocol. We added strongly-typed OM for all of the constructs defined in the Atom Publishing Protocol specification (like ServiceDocument and Workspaces) and put them in the System.ServiceModel.Syndication namespace.
  • Attribute-free Data Contract serialization. The DataContract serializer now supports a model that doesn't require you to put [DataContract]/[DataMember] on every serializable member.
  • Interoperable Object References. The DataContract Serializer now supports an interoperable object reference scheme that allows it to serialize object graphs (not just trees). Thanks to this, Entity Framework types are also serializable via the DataContract serializer.
  • Improved logging/tracing in Partial Trust. We added more of our diagnostic/tracing path to the partial trust sandbox to improve the debuggability of hosted applications running in partial trust.
  • Scalability Improvements on IIS7: It's now possible to plug WCF into IIS7 asynchronously instead of synchronously, which can improve overall throughput and thread utilization on IIS7 for a class of high-latency scenarios.

Tools

  • Enhanced Service Test Client: The Test Client can now test services that use MessageContract/XmlSerializer types as well as Nullable<T>.
  • Hosting Wizard: There's now some tooling support for deploying Service Library projects to a host environment
  • Workflow Designer Performance Improvements: Auto-Save is faster now. A LOT faster.
  • Silverlight Templates: Visual Studio templates for WCF services in Silverlight, nuff said.

We've managed to put a lot into this little release...take a look at the new bits and tell us what you think.

Monday, May 12, 2008 10:43:56 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Friday, May 09, 2008

You should seriously check out Brian's F# blog. It's way good.

Brian is a WCF alum; he owned a hefty chunk of the code in System.ServiceModel.Dispatcher and the 3.5 Web Programming Model work.

It's funny...I used to mistype his name in emails a "Brain McNamara" at least once a week, which actually was a pretty accurate statement.

Anyway, he's over in 41 working on the F# compiler now and blogging up a storm. I'm spending more time getting to know the F# language, and I'm liking what I'm seeing.

Friday, May 09, 2008 8:30:07 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Tuesday, March 18, 2008

Nicholas has a good post on the binding validation WCF does in partial trust.

As he points out, a ServiceHost running in anything less than a fully trusted AppDomin will so some baked-in validation on the bindings being used. Specifically, we have a list of binding elements that are explicitly prohibited in partial trust, and if we catch you trying to use one of these binding elements we'll prevent your service from activating.

This behavior has absolutely nothing (zip, zero, nada) to do with security. For that, we rely on the Code Access Security features implemented by the CLR, like any other framework component.

So why do we do this validation? One reason -- usability. Exceptions at deterministic times (say, Open()) are vastly better than exceptions at random times (say, when you receive a message that triggers a code path that does a demand for a permission you don't have). Having binding validation in place doesn't make the system more secure, but does avoid exposure to a large class of issues that can be pretty hard to reproduce and diagnose.

Monday, March 17, 2008 11:39:52 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Monday, March 10, 2008

Sadly, duty called and I didn't get to make it to Mix '08 this year. To make up for it, I think I'll take a couple days this week to watch some recorded sessions via teh intarweb and then drive to the Indian casino in Everett.

Here's what's in my queue:

http://sessions.visitmix.com/?selectedSearch=T26 -- Justin Smith on the NetFx 3.5 WCF Web Programming Model
http://sessions.visitmix.com/?selectedSearch=T19 – Pablo on talking to Windows Live Services via AtomPub
http://sessions.visitmix.com/?selectedSearch=BT02 – Mike Flasko’s Astoria overview
http://sessions.visitmix.com/?selectedSearch=T22 – Scott Hanselman’s MVC overview
http://sessions.visitmix.com/?selectedSearch=T28 – John Lam on the DLR
http://sessions.visitmix.com/?selectedSearch=T07 – another Astoria talk, this one from Pablo
http://sessions.visitmix.com/?selectedSearch=T13 – our very own EugeneOs on web services and Silverlight

But of course the big one for me is Creating a RESTful API with Windows Communication Foundation, presented by Haider Sabri and some friends from the MySpace developer API team. These guys have been building the public-facing MySpace REST API as a set of WCF services and were kind enough to do a talk at Mix about their experience. They even built a cool demo app -- http://www.restchess.com using WCF and shared the source for everyone to play with. There's a sweet (and highly reusable) OAuth channel in there along with lots of other goodies...thanks guys!

Monday, March 10, 2008 9:51:47 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Friday, January 18, 2008

I've gotten a lot of requests (internally and externally) for requests for resources on how to use the new WCF Web Programming Model features in .NET 3.5.

MSDN has a lot of great content on this stuff, but it's kind of sprinkled around in various places due to the way the MSDN table of contents is laid out. I figured it would be nice to have links to all of the important topics in one place, so here's the "mini-TOC" for the Web Programming Model content:

Conceptual Overviews:

Class Library Reference (not exhaustive):

Configuration Schema:

Samples:

Friday, January 18, 2008 3:49:45 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Tuesday, January 15, 2008

Lots of folks have asked me how to add various XMLism like XML Namespace prefixes to the serialized output of a SyndicationFeed. This is actually easy to do once you know the trick but it's admittedly not the most obvious thing in the world.

The thing to remember is that the System.Xml stack treats prefix declarations as special kinds of attributes. If you want to emit an XML namespace declaration of xmlns:contoso=http://schemas.contoso.com you need to emit attribute whose name is the prefix you're declaring (e.g. "contoso"), whose value is the namespace URI that corresponds to the prefix (e.g. 'http://schemas.contoso.com'). This attribute needs to be in the special XML namespace declaration namespace (!) of http://www.w3.org/2000/xmlns/

Since SyndicationFeed supports additional XML attributes through the AttributeExtensions property, you can do this on SyndicationFeed as follows (using the C# 3.0 collection initializer syntax, natch):

SyndicationFeed feed = new SyndicationFeed()
{

   AttributeExtensions =

  {
     { new XmlQualifiedName("contoso", "
http://www.w3.org/2000/xmlns/"), "http://schemas.constoso.com" }
  }
};

If you like syntactic sugar, here are a few extension methods that add a helper function to all of the OM constructs that support attribute extensibility:

using System;
using System.Xml;
using System.ServiceModel.Syndication;

namespace Samples
{
    public static class SyndicationExtensions
    {
        public static void DeclareNamespace(this SyndicationFeed feed, string prefix, string nsUri)
        {
            feed.AttributeExtensions.Add(new XmlQualifiedName( prefix, "
http://www.w3.org/2000/xmlns/" ), nsUri);
        }

        public static void DeclareNamespace(this SyndicationItem item, string prefix, string nsUri)
        {
            item.AttributeExtensions.Add(new XmlQualifiedName(prefix, "
http://www.w3.org/2000/xmlns/"), nsUri);
        }

        public static void DeclareNamespace(this SyndicationCategory category, string prefix, string nsUri)
        {
            category.AttributeExtensions.Add(new XmlQualifiedName(prefix, "
http://www.w3.org/2000/xmlns/"), nsUri);
        }

        public static void DeclareNamespace(this SyndicationLink link, string prefix, string nsUri)
        {
            link.AttributeExtensions.Add(new XmlQualifiedName(prefix, "
http://www.w3.org/2000/xmlns/"), nsUri);
        }

        public static void DeclareNamespace(this SyndicationPerson person, string prefix, string nsUri)
        {
            person.AttributeExtensions.Add(new XmlQualifiedName(prefix, "
http://www.w3.org/2000/xmlns/"), nsUri);
        }
    }
}

On a side note, I'm becoming a huge fan of extension methods. They are not perfect, but I expect that their existence will have a pretty substantial impact on the way the internals of the framework get factored in future versions...

Tuesday, January 15, 2008 12:07:00 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Friday, January 11, 2008

One of the things that the DataContractSerializer does is create a mapping between CLR type names and XML qnames.

Lots of people know that you can control this mapping on a per-type basis via the [DataContract] attribute, e.g.

namespace Contoso.Serialization
{
  [DataContract( Namespace="http://schemas.contoso.com/2008" )]
  public class Person
  {

     [DataMember]
     public string Name { get; set; }
  }
}

Having to explicitly specify this on every type gets a little laborious, especially if you just want to say "put all types in this CLR namespace into this XML namespace".

Few people know that there's a simple way to do this via the assembly-level ContractNamespaceAttribute:

[assembly: ContractNamespace( "http://schemas.contoso.com/2008", ClrNamespace="Contoso.Serialization" )]

If you have that, then you can just say [DataContract] (sans Namespace="...") and it's just as if you had said [DataContract( Namespace="http://schemas.contoso.com/2008" )] for all [DataContract] types in the Contoso.Serialization namespace.

That comes in handy from time to time and can save some keystrokes.

This has been around since .NET 3.0, but I didn't know about it until recently. Figured not many other people did either :)

Friday, January 11, 2008 7:43:03 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Saturday, January 05, 2008

I thought this post from Ganesh Prasad was both cheeky and refreshing:

Though I like REST and consider it a very elegant model for SOA, it's a little tiresome to hear day in and day out that it's so much more elegant than the SOAP-based Web Services model. In fact, I'm getting so tired of this shrill posturing that I'm going to stick it to the RESTafarians right now, in their own style. Watch.

Paying the RESTafarians Back in Their Own Coin

I think I would get along well with Ganesh.

Saturday, January 05, 2008 12:27:19 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Thursday, August 23, 2007

If you want to use the [WebGet]/[WebInvoke] programming model in WCF, you need an endpoint with the right binding and the right endpoint behavior.

The binding is the out-of-the-box WebHttpBinding. The endpoint behavior can be either WebHttpBehavior or WebScriptEnablingBehavior.

What's the difference between the two?

The WebHttpBehavior is a general-purpose behavior that supports UriTemplate dispatch and POX/JSON/byte stream formats on the wire. Use it for general purpose HTTP/REST/Web-Style services.

The WebScriptEnablingBehavior is a "profile" of the WebHttpBehavior functionality designed specifically for interop with ASP.NET AJAX clients. It adds in some AJAX-isms like the ability to automatically generate ASP.NET AJAX client proxies.

Thursday, August 23, 2007 9:29:31 AM (Pacific Standard Time, UTC-08:00)  #    Comments [3]
 Tuesday, August 21, 2007

I get asked by many, many folks if there's a way to cleanse the .svc file extension from WCF service URI's running in IIS.

Of course there is, and Jon Flanders shows you how.

Thanks for writing that up, Jon!

Tuesday, August 21, 2007 12:55:55 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Thursday, August 09, 2007

Performance is something we take pretty dang seriously on WCF. I had the privilege of wearing the Performance PM hat during the last few milestones of WCF v1, so I got an up close and personal introduction to all the work that goes in to squeezing every last bit of performance possible from a bigtime server stack. I wish I could say I was responsible for the fantastic performance we have in the product today, but that honor rightly belongs to every feature developer on the team -- great perf is something that's baked in from the ground up, and it takes a commitment from every single person involved in the code to make a stack perform to its fullest. Of course, having the SWAT team of BobDimp, ErikC and their roving band of brianiacs didn't hurt either :)

The reason I bring this up is because we release the .NET StockTrader application today, which is an end-to-end real-world app that stacks up WCF 3.0's performance against Websphere 6.1. I'm pretty stoked about the summary results:

  • .NET 3.0 hosted on IIS with an Http binding and XML encoding offers 124% better throughput than the fastest WebSphere/EJB Web Service implementation tested; and 46% better throughput than the JDBC (no entity beans) WebSphere implementation tested.
  • .NET 3.0 self-hosted over Http/XML offers 225% better throughput than the fastest WebSphere/EJB Web Service implementation tested; and 113% better throughput than the JDBC WebSphere implementation tested.
  • .NET 3.0 with binary encoding over a TCP binding offers 488% better throughput than the fastest WebSphere EJB Web service implementation tested; and 284% better throughput than the JDBC WebSphere implementation tested.

Gotta love going fast.

Thursday, August 09, 2007 6:58:13 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]
 Saturday, July 21, 2007

Upgraded to DasBlog 1.9.7 last night -- if you're reading this, things seem to be going ok. Still some issues to work out with Free Text Box and the editing UI, but I'll get to those later. Must read Harry Potter now.

Saturday, July 21, 2007 10:59:55 AM (Pacific Standard Time, UTC-08:00)  #    Comments [3]
 Wednesday, June 06, 2007

Day Three of TechEd Orlando is pretty much in the books -- newsflash: when it rains down here, it really rains.

I've spent most of my time here hanging out in the SOA + Web Services area of the Technical Learning Center. For those of you at Tech Ed, it's the blue one. I'll be there tomorrow as well, so if you have a question about WCF or just want to talk about the web you should come on by.

Tomorrow, my good friends Ed Pinto and Kenny Wolf will be doing a 400-level talk on WCF Architecture and Extensibility. This is the talk to go to if you're interested in exploring WCF from the inside out. It's going to be a great talk; I'll probably pop out of the TLC for an hour or two and go hear the PintoWolf do their thing.

And if you're still here on Friday afternoon, I'm doing a talk on WCF and the Web at 1pm. I'll be talking about UriTemplates, WebGet/WebInvoke, JSON, RSS, and all the other webby goodness I've been blogging about recently. Should be a good time -- hope to see you there.

Wednesday, June 06, 2007 6:52:20 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Wednesday, May 23, 2007

Scott's got some good comments on the Ruby aesthetic.

I find some of the Ruby idioms to be really interesting. Specifically, the attempt to bring programming language closer to the natural language is an admirable goal. That said, I wonder how well they translate and whether this style is ultimately a help or a hindrance to Ruby coders who don't natively speak English (at the very least, it puts a different slant on the globalization problem).

And I know Matz is Japanese, but it seems like a lot of this comes in the framework/standard libary. I think Ruby has landed in an interesting place -- it has a nice mix of core language features (particularly block closures and extensible types) that enable some nice patterns, but the real trick is in the framework and how it makes use of them to enable the idioms that Scott finds so attractive.

C# 3.0 is getting to the point where you can do some (admittedly not all) of the same things -- extension methods and lambda expressions can be pushed pretty far. I'm interested to see what people will do with them and if some of those aesthetics end up crossing over. What will be really interesting is to see how the overall design of the BCL evolves now that we have these core features at the language layer and a few key features (LINQ, WPF, WF) that tend to really light up with libraries that embrace functional rather than inheritance-based extensibility and composition.

Tuesday, May 22, 2007 11:50:48 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]