Default endpoints in WCF 4.0

Starting from WCF 4.0 it’s possible to use a default endpoint in absence of explicit configuration. This means that you can avoid to configure an explicit endpont because of a default mapping between protocol schema and bindings described in the configuration file machine.config.

Here is the default content of that mapping:

    <clear /> 
    <add scheme="http" binding="basicHttpBinding"
                 bindingConfiguration="" /> 
    <add scheme="net.tcp" binding="netTcpBinding" 
                bindingConfiguration="" /> 
    <add scheme="net.pipe" binding="netNamedPipeBinding" 
                 bindingConfiguration="" /> 
    <add scheme="net.msmq" binding="netMsmqBinding"
                 bindingConfiguration="" /> 

For example, in the case of presence of “http” in the protocol, it will be used the default binding “basicHttpBinding” without the need to configure an endpoint explicitly.

Now, to test this new feature all you need is to create a simple service without an explicit endpoints configuration and then read hits configuration such as the following example:

using (ServiceHost host = new ServiceHost(typeof(MyService))
    foreach (ServiceEndpoint end inhost.Description.Endpoints)
         Console.Write("Address:{0}\nBinding:{1}\n", end.Address, 

This code in .Net Framework 4.0 will work fine, while .Net 3.5 would have required the endpoint configuration

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>