Today i fogured out one tricky problem how to create WCF Service and host it into SharePoint 2010.
This is my procedure:
1.) Create “Empty SharePoint Solution”
2.)Add mapped folder “ISAPI”:


3.) Create ‘New Folder’ in this mapped folder called ‘InsideService’.
4.) Click to right button of mouse on mapped folder ‘ISAPI’ and choice ‘Add New Item’. In the category ‘Visual C#’ somewhere down you find ‘WCF Service’. And we named it ‘InsideService’.
5.) Open file IInsideService.cs and change content on this:
[ServiceContract]
public interface IInsideService
{
[OperationContract]
string NameOfMySite();
}
5.) Open file InsideService and change content on this:
[ServiceBehavior]
[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class InsideService : IInsideService
{
public string NameOfMySite()
{
return SPContext.Current.Web.Title;
}
}
6.) Create InsideService.svc, when we want to add this service into SharePoint we have to create it. Creation is very easy, only create for example class and rewrite filename on ‘InsideService.svc’ and content on:
<%ServiceHost Debug=”true” Language=”C#” CodeBehind=”InsideService.cs”
Service=”MartinBodocky.ISAPI.InsideService, MartinBodocky, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3dc8454e5ea842c” %>
Will be very careful to correct format “TYPE,ASSEMBLY,VERSSION,CULTURE,PUBLICKEYTOKEN”.
7.) Before deploy we have to set wcf configuration, but before that we rewrite name of file from ‘app.config’ to ‘web.config’ is very important, because SharePoint cannot find your config. And this file drog and drop to ‘InsideService’ folder. The finally view is there:

8.)This is WCF configuration:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name=”MartinBodocky.ISAPI.InsideServiceBehavior”>
<serviceMetadata httpGetEnabled=”true” />
<serviceDebug includeExceptionDetailInFaults=”false” />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration=”MartinBodocky.ISAPI.InsideServiceBehavior”
name=”MartinBodocky.ISAPI.InsideService”>
<endpoint address=”" binding=”basicHttpBinding”
contract=”MartinBodocky.ISAPI.IInsideService”>
<identity>
<dns value=”http://kp-sp/” />
</identity>
</endpoint>
<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange” />
<host>
<baseAddresses>
<add baseAddress=”http://kp-sp/_vti_bin/InsideService/InsideService/” />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
9.) When you deploy solution in IIS, it appear new virtual directory:

And we have to enable anonymous Authentication:

10.) Finally IISRESET and try our service in browser:

When you find something misunderstable, just write comment
Cheers up guys!