Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 58
#ASP.NET 55
ASP.NET 50
#DOTNET 49
.NET 40
WCF 21
DOTNET 12
c# 8
windows azure 7
SILVERLIGHT 7

Archive · View All
April 2011 9
March 2011 9
February 2011 8
December 2010 7
November 2010 5
September 2010 5
August 2010 5
May 2011 4
October 2010 4
January 2011 2

Default EndPointsin WCF 4.0

Jan 28 2011 2:28AM by Dhananjay Kumar   

For a normal developer like me, had a great challenge working with WCF 3.x was configuration of End Points in config file. Developer had to add endpoints to setup a WCF service. In WCF 4, Defualt End Point is associated with the service, if we don’t configure any WCF endpoint.

 

To see how Default EndPoint works follow the steps below ,

Step1

Create a WCF service application.

Let us create two service contracts

IService1.cs

[ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData();
    }

IService2.cs

[ServiceContract]
    public interface IService2
    {
        [OperationContract]
        string GetMessage();
    }

Now let us implement the service as below,

public class Service1 : IService1, IService2
    {
        public string GetData()
        {
            return "Hello From Iservice1 ";
        }
        public string GetMessage()
        {
            return " Hello From Iservice2";
        }
    }

Step 2

Now we will host this service in a console application, Create a new console application project.

Add reference of WCF service application project and also add reference of System.serviceModel in the console application project.

Note:There is no App.Config associated with console application.

ServiceHost host = new ServiceHost(typeof(WcfService1.Service1),
    new Uri("http://localhost:8080/service"),
    new Uri("net.tcp://localhost:8081/service"));

Here, we are registering two base addresses with the servicehost. One for http binding and other for nettcp binding.

Now we don’t have any configuration for the service EndPoint .ServiceHost will create default EndPoints .

Now ServiceHost will configure EndPoints for two base addresses

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using WcfService1;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceHost host = new ServiceHost(typeof(WcfService1.Service1),
                new Uri("http://localhost:8080/service"),
                new Uri("net.tcp://localhost:8081/service"));
				
            host.Open();
            foreach (ServiceEndpoint se in host.Description.Endpoints)
            {
                Console.WriteLine("Address: " +  se.Address.ToString() +
                    "  Binding: " + se.Binding.Name +
                    " Contract :"+ se.Contract.Name);
            }
            Console.ReadKey(true);
        }
    }
}

Output would be

Output

The default protocol mapping is as below,

<protocolMapping>
  <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=""/>
</protocolMapping>

Since HTTP is mapped with basicHttpBinding , so we got the default EndPoint with basicHttpBinding.

Default EndPoint will only get created if there is not a single Endpoint configured. If we add any single EndPoint then all then there won’t be any default EndPointget configured.

If we add one EndPoint as below,

host.AddServiceEndpoint(typeof(IService1),
    new WSHttpBinding(),
    "myBinding");

We added one service EndPoint and now the output we would get for below code ad below,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using WcfService1;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceHost host = new ServiceHost(typeof(WcfService1.Service1),
                new Uri("http://localhost:8080/service"),
                new Uri("net.tcp://localhost:8081/service"));
            host.AddServiceEndpoint(typeof(IService1),
                new WSHttpBinding(),
                "myBinding");
            host.Open();
            foreach (ServiceEndpoint se in host.Description.Endpoints)
            {
                Console.WriteLine("Address: " +  se.Address.ToString() +
                    "  Binding: " + se.Binding.Name +
                    " Contract :"+ se.Contract.Name);
            }
            Console.ReadKey(true);
        }
    }
}

Output

Output

Now we see that if we configure aEndPoint then WCF does not support default Endpoints.

Tags: #DOTNET, WCF, #ASP.NET, ASP.NET, BRH, .NET,


Dhananjay Kumar
49 · 4% · 1198
1 Readers Liked this
Guru Samy Liked this on 3/30/2012 4:26:00 AM
Profile · Blog
1
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Default EndPointsin WCF 4.0" rated 5 out of 5 by 1 readers
Default EndPointsin WCF 4.0 , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]