创建了一个自定义Web服务,该服务作为SP2013的服务器场解决方案部署。在VS Project中为此服务添加了ISAPI文件夹的管理路径。
添加了C:\ inetpub \ wwwroot \ wss \ VirtualDirectories \ 80
<location path="_vti_bin/FCWebServices.svc">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
还添加了C:\ Program Files \ Common Files \ microsoft shared \ Web Server Extensions \ 15 \ ISAPI \ web.config
<location path="FCWebServices.svc">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
从IE或Chrome调用适当的路径“http://host/_vti_bin/FCWebServices.svc/GetOffCanvasNavigation” - 我将预期的数据作为HTTP 200返回。从JQuery $ .ajax调用调用我得到401(只调用webservice方法本身,即使任何SP2013 API调用已注释掉。
我希望这个Web服务调用是匿名的,它将面向公众面临的SharePoint 2013网站。
以下是Web请求的标头转储:
Request URL: http://host/_vti_bin/FCWebServices.svc/GetOffCanvasNavigation
Request Method: OPTIONS
Status Code: 401 / Unauthorized
- Request Headers
Accept: */*
Accept-Encoding: gzip, deflate
Access-Control-Request-Headers: content-type, accept
Access-Control-Request-Method: GET
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 0
Host: fcit-mcvm2
Origin: file:
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586
- Response Headers
Access-Control-Allow-Origin: *
Content-Length: 16
Content-Type: text/plain; charset=utf-8
Date: Mon, 06 Jun 2016 14:50:50 GMT
Location: /_login/default.aspx?ReturnUrl=%2f_vti_bin%2fFCWebServices.svc%2fGetOffCanvasNavigation
MicrosoftSharePointTeamServices: 15.0.0.4569
request-id: eb85839d-472b-d06e-9fc9-c1e40fcec15a
Server: Microsoft-IIS/8.5
SPIisLatency: 155
SPRequestDuration: 1336
SPRequestGuid: eb85839d-472b-d06e-9fc9-c1e40fcec15a
WWW-Authenticate: NTLM
X-Content-Type-Options: nosniff
X-FRAME-OPTIONS: SAMEORIGIN
X-MS-InvokeApp: 1; RequireReadOnly
X-Powered-By: ASP.NET
记录控制台错误:
HTTP401: DENIED - The requested resource requires user authentication.
(XHR): OPTIONS - http://host/_vti_bin/FCWebServices.svc/GetOffCanvasNavigation
我需要做些什么来消除401的?
标记
答案 0 :(得分:0)
我最终在sharepoint之外创建了一个Web API解决方案,并与CSOM集成。为了完成我原本想做的事情,我不得不做很多标题黑客攻击并在SharePoint中解决,希望它不会破坏。