Replicating the Demo from the PDC05 COM200 Session

If you didn't attend PDC05 this year and missed the COM200 - Applications and Communications Roadmap: Platforms Presents and Futures session from PDC 05, you can view it online.  In the session, Don Box and Mike Vernal walk through some interesting WCF demos including Mike converting WSDL to CLR types by hand, which really drives home the association of WSDL to WCF. 

You can go to Don's blog to see the code and config used in the COM200 presentation.  If you are trying to replicate this using the PDC bits and haven't installed XLINQ, you can modify the code slightly to achieve the same results:

 public class XBodyWriter : BodyWriter
{
    public XBodyWriter() : base(true) { }

    protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
    {
        Process[] processes = Process.GetProcesses();
        writer.WriteStartElement("Processes");
        foreach (Process p in processes)
        {
            writer.WriteStartElement("ProcessData");
            writer.WriteElementString("Name", p.ProcessName);
            writer.WriteElementString("WorkingSet", p.WorkingSet64);
            writer.WriteEndElement();
        }
        writer.WriteEndElement();
    }
}

Another change you might want to make to use the wsHttpBinding shown in the demo is to include a behavior for the service.  You can see where they reference the "LapServiceBehaviors" behavior within the video, but it isn't shown in the video or on Don's blog.  I borrowed the listing below from the WS-Security: Certificate example.  There is a .bat file in that example that shows how to install the appropriate X.509 cert to make this work.

      <behaviors>
<behavior
configurationName="LapServiceBehaviors"
returnUnknownExceptionsAsFaults="true" >
<serviceCredentials>
<serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</behaviors>

Finally, to see the actual message on the wire, you can configure message-level tracing for WCF, as shown in my previous blog.

Mike Vernal did a great job as a human svcutil.exe in the demo, definitely worth a watch.