0

Once i've created custom web extension for another SP farm, and had no troubles here, still works, but now i don't know where else to dig. I follow well-know tutorial - https://jbarkes.blogspot.com/2014/04/sharepoint-2013-create-custom-wcf-rest.html

And i cannot call a simpliest get-method, the error is:

The type 'WEBExt.UnlockService, WEBExt, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxx', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

My service looks like: UnlockService.svc.cs:

using System;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel.Web;
using WEBExt.Models;
using System.ServiceModel.Activation;
using System.Net.Http;
using Newtonsoft.Json;

namespace WEBExt
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class UnlockSerivce : IUnlockService
    { 
        public string Hi()
        { return "Hi!"; }       
    }
}

IUnlockService.cs:

using System.Threading.Tasks;
using System.ServiceModel;
using System.ServiceModel.Web;
using WEBExtExt.Models;

namespace WEBExt { 

    [ServiceContract]
    interface IUnlockService
    {   
        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "Hi")]
        string Hi();
    }
}

IUnlockService.cs:

<%@ ServiceHost Language = "C#" Debug="true"
    Service="WEBExt.UnlockService, $SharePoint.Project.AssemblyFullName$"
    CodeBehind="UnlockService.svc.cs"    Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory,
    Microsoft.SharePoint.Client.ServerRuntime, Version = 16.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c" %>

The service dll is deployed to GAC just as referenced dll's.

i've got very strange this in my logs:

w3wp.exe (0x4050) 0x0D80 SharePoint Foundation Claims Authentication af32k Medium Claims Windows Sign-In: Sending 401 for request 'https://mysp/_vti_bin/UnlockService.svc/Hi' because the user is not authenticated and resource requires authentication. 4d6c17a0-1874-106e-1652-adb5c775fbe2 w3wp.exe (0x4050) 0x0D80 SharePoint Foundation General b6p2 Medium Sending HTTP response 401 - text/plain:401 UNAUTHORIZED. 4d6c17a0-1874-106e-1652-adb5c775fbe2

Browser didn't ask for credentials. I'm guessing this may be configuration issue but i have no idea what else to check.

Any ideas?

1 Answer 1

0

By default, you may need to use HTTP basic auth.

Try adding an Authorization header with {user}:{password}.

On our farm, our services automatically look for HTTP basic auth. Not sure how you change this as it is something I'm currently looking into.

Your Answer

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

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