What is a WCF Endpoint?

A WCF Service has three essential things; the Address that has info on where the Service resides, the Binding that has information on how to communicate and use the service and the Contract which defines what the service does. A combination of all this is a WCF Endpoint.

All communication with a Windows Communication Foundation (WCF) service occurs through the endpoints of the service. Endpoints provide clients access to the functionality offered by a WCF service.

Each endpoint consists of four properties:

·         An address that indicates where the endpoint can be found.

·         A contract that identifies the operations available.

·         A set of behaviors that specify local implementation details of the endpoint

·         A binding that specifies how a client can communicate with the endpoint.

 

Here is a sample code on how to create a WCF Service Endpoint.

[ServiceContract]

public interface ICalculator

{

   [OperationContract]

   double Add(double n1, double n2);

   [OperationContract]

   double Subtract(double n1, double n2);

   [OperationContract]

   double Multiply(double n1, double n2);

   [OperationContract]

   double Divide(double n1, double n2);

}

 

And here is how you implement the above Service Endpoint

public class CalculatorService : ICalculator

{

   public double Add(double n1, double n2)

   {

      return n1 + n2;

   }

   public double Subtract(double n1, double n2)

   {

      return n1 - n2;

   }

   public double Multiply(double n1, double n2)

   {

      return n1 * n2;

   }

   public double Divide(double n1, double n2)

   {

      return n1 / n2;

   }

}

 

 

You can also Create a Service Endpoint using the config file. In the examples above, I showed how to create an WCF Service Endpoint using C# code, but here below you will see how to create a Service endpoint using the config file.

<configuration>

 

  <appSettings>