我对在 SharePoint 中托管 wcf 的问题失去了理智。我无法访问我的 Web 服务,我在 SharePoint 网站上看到了它,但是当我单击它时,我收到一条错误消息
编辑:我删除了我的公钥,以确保问题不是来自这里
所以我有我的 ASP.NET Web应用程序,它被称为:Foo.PS2016.PSIExtension。
凭借其 iservice 和服务(非常简单的一个(:
服务:
namespace Foo.PS2016.PSIExtension
{
[ServiceContract]
interface IService
{
[OperationContract]
bool isAlive();
}
}
服务:
namespace Foo.PS2016.PSIExtension
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
internal class Service : IService
{
public bool isAlive()
{
return (true);
}
}
}
其Service.svc:
<%@ ServiceHost Language="C#" Debug="true" Service="Foo.PS2016.PSIExtension.Service" %>
及其网络服务:
<?xml version="1.0" encoding="utf-8"?>
<!--
-->
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="http://sfd-2016-01/sites/pwa/" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
我有我的 SharePoint 解决方案及其文件夹 ISAPI=>PSI=>Foo.PS2016.PSIExtension.svc :
版本、区域性和公钥来自文件中的 powershell 命令:Foo.PS2016.PSIExtension.dll
所以从今天早上开始,我一直在这个问题上,所以如果有人有一些想法来帮助我
所以这是我的 ajax 调用的结果:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:o="urn:schemas-microsoft-com:office:office" lang="en-us" dir="ltr">
<head><meta name="GENERATOR" content="Microsoft SharePoint" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Expires" content="0" /><meta http-equiv="X-UA-Compatible" content="IE=8"/><meta name="ROBOTS" content="NOHTMLINDEX" /><title>
Error
</title><link rel="stylesheet" type="text/css" href="/_layouts/15/1033/styles/corev15.css?rev=i237P0%2BWmCDIsNnTvKWmyg%3D%3DTAG0"/>
<link rel="stylesheet" type="text/css" href="/_layouts/15/1033/styles/error.css?rev=uLsAgejtz6uU3M4tXKgEfA%3D%3DTAG0"/>
<script type="text/javascript" src="/_layouts/15/1033/initstrings.debug.js?rev=FPxEulJ9Nz3gxtb2SaxF6g%3D%3DTAG0"></script>
<script type="text/javascript" src="/_layouts/15/init.debug.js?rev=2nn1mwPjUX5aE85AUUjDGw%3D%3DTAG0"></script>
<script type="text/javascript" src="/ScriptResource.axd?d=GIJq-Z4bxUgQ1eeUBIHs5TQTn3kW6sT7yUXQTl4rpjULIbN8l-8p5XVhLDaSql7d5A-3pUW-QYv9cNcSN8liy_MdG4bV-tm3jPg_qX7_SzwnVcDWWxcD7gCBFnjOMi41nNZ1dTrbIXVUnjy2b65YO3EoqipnBU5ZsFUeYIzPrruiuztdGyeUat-m3R42Mv8a0&t=2a48f442"></script>
<script type="text/javascript" src="/_layouts/15/blank.js?rev=Y52JlQQL8Ld7e28E1u1PXw%3D%3DTAG0"></script>
<script type="text/javascript" src="/ScriptResource.axd?d=DtxdsIxZ13GzDhO3js7m9Y5qqFa6jCdy5nWUs3QtO0OiymWNuz8ei7lyf7bZCIumCWC3yWeU3nI7HsPj_4MfIjnCYUbbGjzuUKdAGAG2R016R_w2gdgT06fcxkcT6lssmCtiM7sqvDESEv9aa4lcHigN66DWM8TOlx0fEEBwiQpwSE8NNqGUPcIkkyx2wGxEmyZMGotZO6OcGHT_8EAtNg2&t=2a48f442"></script>
<script type="text/javascript">RegisterSod("require.js", "u002f_layoutsu002f15u002frequire.js?rev=u00252BRRfOnYW0VaAgSoCgcIN8Qu00253Du00253DTAG0");</script>
<script type="text/javascript">RegisterSod("strings.js", "u002f_layoutsu002f15u002f1033u002fstrings.debug.js?rev=ClRR65u00252FJrktrUN4XIKIREQu00253Du00253DTAG0");</script>
<script type="text/javascript">RegisterSod("sp.res.resx", "u002f_layoutsu002f15u002f1033u002fsp.res.js?rev=MbB92HT8biYuFau00252B1vTMilAu00253Du00253DTAG0");</script>
<script type="text/javascript">RegisterSod("sp.runtime.js", "u002f_layoutsu002f15u002fsp.runtime.debug.js?rev=Vehku00252FiThFRjckdql8i15Agu00253Du00253DTAG0");RegisterSodDep("sp.runtime.js", "sp.res.resx");</script>
<script type="text/javascript">RegisterSod("sp.js", "u002f_layoutsu002f15u002fsp.debug.js?rev=fIEkblNHoC3DmVwyA9fW7Qu00253Du00253DTAG0");RegisterSodDep("sp.js", "sp.runtime.js");RegisterSodDep("sp.js", "sp.ui.dialog.js");RegisterSodDep("sp.js", "sp.res.resx");</script>
<script type="text/javascript">RegisterSod("sp.init.js", "u002f_layoutsu002f15u002fsp.init.debug.js?rev=r7eoFYyCjoRR1v71zF6w6Au00253Du00253DTAG0");</script>
<script type="text/javascript">RegisterSod("sp.ui.dialog.js", "u002f_layoutsu002f15u002fsp.ui.dialog.debug.js?rev=JWExCHnIyo1aEflEW9vZxQu00253Du00253DTAG0");RegisterSodDep("sp.ui.dialog.js", "sp.init.js");RegisterSodDep("sp.ui.dialog.js", "sp.res.resx");</script>
<script type="text/javascript">RegisterSod("core.js", "u002f_layoutsu002f15u002fcore.debug.js?rev=uhzu00252B5jl6DViyR8K7N2onWQu00253Du00253DTAG0");RegisterSodDep("core.js", "strings.js");</script>
<script type="text/javascript">RegisterSod("foldhyperlink.js", "u002f_layoutsu002f15u002ffoldhyperlink.debug.js?rev=hsjDlcu00252BMqWuhI3IZAGCRqQu00253Du00253DTAG0");</script>
<meta name="Robots" content="NOINDEX " />
<meta name="SharePointError" content="0" />
<link rel="shortcut icon" href="/_layouts/15/images/favicon.ico?rev=40" type="image/vnd.microsoft.icon" /></head>
<body id="ms-error-body" onload="if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">
<form method="post" action="./error.aspx?ErrorText=The+type+%27Test.PS2016.PSIExtension.Service%2c+Test.PS2016.PSIExtension%2c+Version%3d1.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3dnull%27%2c+provided+as+the+Service+attribute+value+in+the+ServiceHost+directive%2c+or+provided+in+the+configuration+element+system.serviceModel%2fserviceHostingEnvironment%2fserviceActivations+could+not+be+found." id="aspnetForm" onsubmit="if (typeof(_spFormOnSubmitWrapper) != 'undefined') {return _spFormOnSubmitWrapper();} else {return true;}">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTMxMjY5NDA5NQ9kFgJmD2QWAgIBD2QWAgIDD2QWAgIJD2QWAgIBD2QWBAIDDw8WAh4HVmlzaWJsZWhkZAIHD2QWAgIBDw8WAh4XTGlua1RpdGxlV2hlbkZvbGRDbG9zZWQFEVRlY2huaWNhbCBEZXRhaWxzZBYIZg9kFgICAQ8PZBYCHgdvbmNsaWNrBcgBRW5zdXJlU2NyaXB0UGFyYW1zKCdmb2xkaHlwZXJsaW5rLmpzJywgJ1RvZ2dsZUZvbGRUZXh0JywgJzYzYzE2ZTE0ZDczZjQ1ODE4YTRlNmU4YjNmODY2Zjg4JywgJ2N0bDAwX1BsYWNlSG9sZGVyTWFpbl9Gb2xkTGlua19fbW9yZURldGFpbHNMaW5rJywgJ1RlY2huaWNhbCBEZXRhaWxzJywgJ1RlY2huaWNhbCBEZXRhaWxzJyk7O3JldHVybiBmYWxzZTsWAgIBDw8WAh4EVGV4dAURVGVjaG5pY2FsIERldGFpbHMWBB4EaHJlZgUBIx8CBRtQcmV2ZW50RGVmYXVsdE5hdmlnYXRpb24oKTtkAgUPDxYCHwBoZGQCCQ8PFgIfAwU0Q29ycmVsYXRpb24gSUQ6IDZiMDc1ZTllLWUxZmQtMTBhYy04N2FkLTI3M2U4NTIyYjZmYmRkAgsPDxYCHwMFI0RhdGUgYW5kIFRpbWU6IDQvMTYvMjAxOCAxOjQ5OjMyIFBNZGRk/Ntc91GhLAEgVx/VJMcHSI1WvxzG6XMahftfMlC9Lxc=" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=kqzbgiHYRPrIk2c8aGZXXtswgMsrN6SqxII1hyFPNd1D82NA8x9uOyjyzjXfPaUCFQZbznkKisM-JIwuoGt2n00XLarOKlQh2_rmdbXjf981&t=636160876665894255" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var g_presenceEnabled = true;
var g_wsaEnabled = false;
var g_correlationId = '6b075e9e-e1fd-10ac-87ad-273e8522b6fb';
var g_wsaQoSEnabled = false;
var g_wsaQoSDataPoints = [];
var g_wsaRUMEnabled = false;
var g_wsaLCID = 1033;
var g_wsaListTemplateId = null;
var g_wsaSiteTemplateId = 'STS#0';
var _fV4UI=true;var _spPageContextInfo = {webServerRelativeUrl: "u002f", webAbsoluteUrl: "http:u002fu002fsfd-2016-01", siteAbsoluteUrl: "http:u002fu002fsfd-2016-01", serverRequestPath: "u002f_layoutsu002f15u002ferror.aspx", layoutsUrl: "_layoutsu002f15", webTitle: "Root Site Collection", webTemplate: "1", tenantAppVersion: "2395466148", isAppWeb: false, webLogoUrl: "_layoutsu002f15u002fimagesu002fsiteicon.png", webLanguage: 1033, currentLanguage: 1033, currentUICultureName: "en-US", currentCultureName: "en-US", clientServerTimeDelta: new Date("2018-04-16T11:49:32.8917464Z") - new Date(), updateFormDigestPageLoaded: new Date("2018-04-16T11:49:32.8917464Z"), siteClientTag: "0$$16.0.4507.1000", crossDomainPhotosEnabled:false, webUIVersion:15, webPermMasks:{High:2147483647,Low:4294967295}, pagePersonalizationScope:1,userId:1073741823,userLoginName:"SHAREPOINT\system", systemUserKey:"S-1-0-0", alertsEnabled:true, siteServerRelativeUrl: "u002f", allowSilverlightPrompt:'True', isSiteAdmin: true};Flighting.ExpFeatures = [480215056,1880287568,1561350208,302071836,3212816,69473024,4194310,-2113396707,268502022,-872284160,1049232,-2147421952,65536,65536,2097472,917504,-2147474174,1372324107,67108882,0,0,-2147483648,2097152,0,0,32768,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32768];//]]>
</script>
<script src="/_layouts/15/blank.js?rev=Y52JlQQL8Ld7e28E1u1PXw%3D%3DTAG0" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
if (typeof(DeferWebFormInitCallback) == 'function') DeferWebFormInitCallback();//]]>
</script>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="F3F6CE2F" />
</div>
<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ctl00$ScriptManager', 'aspnetForm', [], [], [], 90, 'ctl00');
//]]>
</script>
<div id="ms-error-header" class="ms-pr">
<h1 class="ms-core-pageTitle">
<div id="ctl00_PlaceHolderPageTitleInTitleArea_ErrorPageTitlePanel">
Sorry, something went wrong
</div>
</h1>
<div>
</div>
</div>
<div id="ms-error">
<div id="ms-error-top">
</div>
<div id="ms-error-content">
<div id="ms-error-error-content">
<div id="DeltaPlaceHolderMain">
<div>
<span id="ctl00_PlaceHolderMain_LabelMessage">The type 'Test.PS2016.PSIExtension.Service, Test.PS2016.PSIExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.</span>
</div>
<div id="ctl00_PlaceHolderMain_FoldPanel" class="ms-error-detailsFold">
<div id="ctl00_PlaceHolderMain_FoldLink_foldLinkWrapper">
<div id="ctl00_PlaceHolderMain_FoldLink_foldLinkPanel" class="ms-foldHyperLink-panel" onclick="EnsureScriptParams('foldhyperlink.js', 'ToggleFoldText', '63c16e14d73f45818a4e6e8b3f866f88', 'ctl00_PlaceHolderMain_FoldLink__moreDetailsLink', 'Technical Details', 'Technical Details');;return false;">
<a id="ctl00_PlaceHolderMain_FoldLink__moreDetailsLink" class="ms-commandLink ms-floatLeft" href="#" onclick="PreventDefaultNavigation();">Technical Details</a>
<div class="ms-clear"></div>
</div>
</div><div class="ms-hide" id="63c16e14d73f45818a4e6e8b3f866f88">
<div>
<p>
<span class="ms-descriptiontext">
</span>
</p>
<p>
<span class="ms-descriptiontext">
<div id="ctl00_PlaceHolderMain_FoldLink_WSSEndUser_troubleshootingPanel">
<span id="ctl00_PlaceHolderMain_FoldLink_helptopic_WSSEndUser_troubleshooting"><a title="Troubleshoot issues with Microsoft SharePoint Foundation. - Opens in new window" href="javascript:HelpWindowKey('WSSEndUser_troubleshooting')">Troubleshoot issues with Microsoft SharePoint Foundation.</a></span>
</div>
</span>
</p>
<p>
<span id="ctl00_PlaceHolderMain_FoldLink_RequestGuidText" class="ms-metadata">Correlation ID: 6b075e9e-e1fd-10ac-87ad-273e8522b6fb</span>
</p>
<p>
<span id="ctl00_PlaceHolderMain_FoldLink_DateTimeText" class="ms-metadata">Date and Time: 4/16/2018 1:49:32 PM</span>
</p>
</div>
</div>
</div>
<div class="ms-error-techMsg">
<hr />
</div>
<script type="text/javascript">// <![CDATA[
var gearPage = document.getElementById('ms-loading-box');
if(null != gearPage)
{
gearPage.parentNode.removeChild(gearPage);
document.title = "Error";
}
function _spBodyOnLoad()
{
var intialFocus = (document.getElementById("ctl00_PlaceHolderMain_FoldLink__moreDetailsLink"));
try
{
intialFocus.focus();
}
catch(ex)
{
}
}
function _onmessage(e)
{
if (e && window.JSON)
{
var origin = e.origin;
var data = e.data;
if (window.console && window.console.log)
{
console.log("ErrorPage.OnMessage: Origin=" + origin + ", Data=" + data);
}
var requestInfo = JSON.parse(data);
if (requestInfo && (requestInfo.command == 'Ping' || requestInfo.command == 'Query'))
{
var requestGuidElem = (document.getElementById("ctl00_PlaceHolderMain_FoldLink_RequestGuidText"));
var responseInfo = {};
responseInfo.command = requestInfo.command;
responseInfo.postMessageId = requestInfo.postMessageId;
responseInfo.responseAvailable = false;
responseInfo.errorCode = -1007;
var errorMessage;
if (requestGuidElem)
{
errorMessage = requestGuidElem.textContent;
if (typeof(errorMessage) == "undefined")
{
errorMessage = requestGuidElem.innerText;
}
}
if (typeof(errorMessage) == "undefined")
{
errorMessage = "Error";
}
responseInfo.errorMessage = errorMessage;
if (window.parent && window.parent.postMessage)
{
data = JSON.stringify(responseInfo);
if (window.console && window.console.log)
{
console.log("ErrorPage.PostMessage: Origin=" + origin + ", Data=" + data);
}
window.parent.postMessage(data, origin);
}
}
}
}
if (window.addEventListener) {
window.addEventListener('message', _onmessage, false);
}
else if (window.attachEvent) {
window.attachEvent('onmessage', _onmessage);
}
// ]]>
</script>
</div>
</div>
<div id="ms-error-gobackcont" class="ms-calloutLink">
<a href="/" class='ms-calloutLink' id="ctl00_PlaceHolderGoBackLink_idSimpleGoBackToHome">Go back to site</a>
</div>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
var g_MinimalDownload = true;var g_WebServerRelativeUrl = "/";var _spFullDownloadList = ['closeconnection', 'download', 'signout', 'xlviewer', 'wordviewer', 'wordeditor', 'powerpoint', 'powerpointframe', 'onenote', 'visiowebaccess', 'storefront', 'wopiframe', 'appredirect', 'wfstart', 'developertools'];
//]]>
</script>
</form>
</body>
</html>
将.svc
文件更改为:
<%@ ServiceHost Language="C#" Debug="true"
Service="Foo.PS2016.PSIExtension.Service, $SharePoint.Project.AssemblyFullName$"
CodeBehind="Service.cs"
Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
MultipleBaseAddressWebServiceHostFactory
动态创建配置,以便您可以摆脱web.config
修改,并且您的 REST 端点将在部署后开箱即用。
并使用 WebGet
属性装饰您的接口方法:
[WebGet(UriTemplate = "isAlive", BodyStyle = WebMessageBodyStyle.Bare)]
此外(不一定(将BasicHttpBindingServiceMetadataExchangeEndpointAttribute
添加到您的课程中
正如我在评论中所说,本教程将逐步完成所有操作,因此请使用它!