Violet Devsec

Windows Communication Foundation (WCF), which is a unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments.

  1. Start a new class library project under your solution.
  2. Define the service contract

    We are defining the service contract. The service contract specifies what operations the service supports. An operation can be thought of as a Web service method. You create service contracts by defining a C# or Visual Basic interface. An interface has the following characteristics:

    • The interface should import System.ServiceModel class.
    • Each method in the interface corresponds to a specific service operation.
    • For each interface, you must apply the ServiceContractAttribute attribute.
    • For each operation/method, you must apply the OperationContractAttribute attribute.
  3. The next step for creating a WCF application is to add code to implement the WCF service interface that you created in the previous step.
  4. Start another Console application project under your solution. This will be acting as the host for your service.
  5. Your application source code files will look like below,
  6. Program.cs : ServiceHost

    App.config : This config file hosts the service in the mentioned service URL. You can mention the machine name and designated port to uniquely host your service.

  7. Write a Client console application to consume the service.
  8. Program.cs : ServiceClient

  9. Start host application and generate the proxy and config files from the metadata exchange end point using “svcutil”.