If you have existed WCF service library and want to host this WCF serivce in your ASP.NET MVC4 application I have prepared this short how-to.

For example you have WCF service located in FooWCF assebly and  MVC4 application located in BarWeb project.

Open BarWeb project and add reference to FooWCF assebly.

Now, add testService.svc WCF Service file in to BarWeb project, remove ItestService.cs and testService.svc.cs files from project.

Open testService.svc and replace

<%@ ServiceHost Language="C#" Debug="true" Service="testForBlock.testService" CodeBehind="testService.svc.cs" %>

with

<%@ ServiceHost Language="C#" Debug="true" Service="FooWCF.Service1" %>

Then open web.config and add:

<system.serviceModel>
    <services>
      <service behaviorConfiguration="FooWCF.Behavior" name="FooWCF.Service1">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="" name="BasicHttpBindingEndpoint" contract="FooWCF.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="/rest" binding="webHttpBinding" contract="FooWCF.IService" behaviorConfiguration="restBehavior" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" name="MexHttpBindingEndpoint" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
           <add baseAddress="http://localhost/testService.svc"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="FooWCF.Behavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="restBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

We have used this behaviour in Advanced Tic Tac Toe because when we start creating web based version of this game we already have WCF service library with all game logic.