wcf Getting started with wcf Simple WCF service


Minimal requirements for WCF service is one ServiceContract with one OperationContract.

Service contract:

public interface IDemoService
    CompositeType SampleMethod();

Service contract implementation:

public class DemoService : IDemoService
    public CompositeType SampleMethod()
        return new CompositeType { Value = "foo", Quantity = 3 };

Configuration file:

<?xml version="1.0"?>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2"/>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>


public class CompositeType
    public string Value { get; set; }

    public int Quantity { get; set; }