Archives / 2006 / October
  • WCF Extensibility - Part 2

    Service Description

     Service Description at Runtime

    Figure 2. ServiceDescription at runtime


    The Service Description is the heart of the service and is created when a ServiceHost or client ChannelFactory is created to describe all aspects of the service, endpoints and behaviors. This description is a logical view of what the WCF runtime is going to build when the Open method on the ServiceHost is executed, and also is used to generate the WSDL and policy metadata for the service. This metadata is exposed through the ServiceDescription class and the Description property on the ServiceHost and can be changed, for example, by injecting behaviors. To build the ServiceDescription information the WCF runtime first reflects over the service types and then it loads the service configuration. This information is then used when you execute the Open method of the ServiceHost to build the runtime.

    In the code shown below you can see how the service description information could be accessed and modified:


    // Construct the ServiceHost
    ServiceHost host = new ServiceHost(typeof(EchoService), new Uri(“http://localhost/echo”) );
    // Add endpoints to description
    host.AddServiceEndpoint(typeof(IEchoService), new BasicHttpBinding(), “”);
    // You can access the Description property of the host
    // And you can change things before calling Open
    foreach( ServiceEndpoint endpoint in host.Description.Endpoints )
             // Add My behavior to all Http endpoints
             If( endpoint.Uri.Scheme == “http” )
                     endpoint.Behaviors.Add( new MyHttpBehavior() );
    // Open the Host

    Next post: Building a Custom ServiceHost


    Andrés G Vettori
    EDS Top Gun - .NET Capability Architect

    Leader of the C# Community of the Microsoft Users Group Argentina


  • Upgraded to Vista RC2

    Last week I upgraded my personal machine to the Vista RC2 version. It was running RC1 and for the most part it worked well, except for some blue screens and some extrange behavior with my video card making my machine to loose video after some time. This machine had Vista Beta2 but this version started to degrade after some time to the point I couldn't even login. At that time I recovered a backup of everything I needed and perform a clean install of RC1.


  • I'm back online

    Well, I have been out of the blogosphere for quite some time, but now I'm back!