I'm trying to make a WCF Rest service inside SharePoint. I'm using webHttpBinding as the binding and "WebGet" attributes on my service methods. I deployed in a standard web application and it worked very well. Then, I deployed to SharePoint (ISAPI folder) and didn't work. I googled about it and the unique solution I found is to make my WCF folder anonymous. Doing this the service worked fine but I need to get the user that is accesing my service.

So, is there any way to configure a WCF service using webHttpBinding as binding using authentication?

My web.config file is this:

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <service behaviorConfiguration="Behaviour1" name="PoC.WCF.MockData">
            <endpoint address="rest" behaviorConfiguration="RestBehaviour" binding="webHttpBinding" contract="PoC.WCF.IMockData"></endpoint>
            <behavior name="Behaviour1">
                <serviceMetadata httpGetEnabled="true"/>
            <behavior name="RestBehaviour">

The service contract interface is this:

using System.ServiceModel;
using System.ServiceModel.Web;

namespace PoC.WCF
    public interface IMockData
        [WebGet(UriTemplate = "")]
        string DoWork();

        [WebGet(UriTemplate = "/{message}")]
        string GetMessage(string message);

1 Answer 1


I get it after few days of googling and testing. The solution is very easy and you don't have to do anything in your development excepting use a factory on your service. This link explain what factory use depending on the service type: WCF Services in SharePoint Foundation 2010

So, the solution to my problem is to modify the "svc" file and add the factory you need. In my case, for a Rest service, I have to use "MultipleBaseAddressWebServiceHostFactory". This is my code:

<%@ ServiceHost 
    Service="PoC.WCF.MockData, PoC.WCF, Version=, Culture=neutral, PublicKeyToken=0a1a45d52b868570"
    Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.