小编Pet*_* P.的帖子

SharePoint 2013中的自定义Web服务,具有模拟功能

对于SharePoint 2010,我们使用自定义Web服务(非SOAP!)在浏览器显示的页面中为JS代码提供一些第三方数据.这是敏感数据,因此我们使用模拟来确保只有合适的用户才能访问它.我们的解决方案在SharePoint 2013中不再起作用.由于原始解决方案非常复杂,我在SP 2013中构建了一个小而简单的服务,以研究如何设置具有模拟的Web服务.该服务部署到ISAPI的子文件夹.

这是没有冒充的基础,它起作用:

TestService.svc:

<%@ ServiceHost 
    Language="C#"
    Debug="true" 
    Service="Sandbox.TestService, $SharePoint.Project.AssemblyFullName$" 
    CodeBehind="TestService.svc.cs" 
    Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Run Code Online (Sandbox Code Playgroud)

TestService.svc.cs中的代码是:

using Microsoft.SharePoint.Client.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Activation;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Sandbox
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class TestService
    {
        [OperationContract]
        [WebGet(UriTemplate = "GetAllNumbers",
            ResponseFormat = WebMessageFormat.Json)]
        List<int> GetAllNumbers()
        {
            List<int> result = new List<int>();
            result.AddRange(new[] { 1, 1, 2, 3, 5, 8, 13 });
            return result;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我执行GET时,http://pc00175/_vti_bin/Sandbox/TestService.svc/GetAllNumbers我收到预期的共鸣[1,1,2,3,5,8,13].好到目前为止.现在我尝试使用模拟: …

sharepoint impersonation wcf web-services sharepoint-2013

5
推荐指数
1
解决办法
1516
查看次数