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
What we have in WCF
I have written a white paper on WCF extensibility and I would like to share it with the community so I have attached a copy to this post in Word 2003 format.
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 found the WCF version of the WSE3 compression filters on the Pablo Cribaro's blog where he published an updated WCF RC1 version.
I have been playing with the cool PowerThreading library created by Jeffrey Richter from Wintellect (found in http://www.wintellect.com/MemberOnly/PowerThreading.aspx ) and replaced an old implementation of a custom thread pool we already had.
You can download the latests Retina.NET version from http://workspaces.gotdotnet.com/retina
Well, I have been out of the blogosphere for quite some time, but now I'm back!