【发布时间】:2010-02-03 06:46:43
【问题描述】:
我正在使用 JQuery 调用 SharePoint Web 服务 (Webs.asmx) 以获取所有子网站的列表:
$(document).ready(function() {
var hrefParts = window.location.href.split('/');
var wsURL = "";
for (i = 0; i < (hrefParts.length - 2); i++) {
if (i > 0)
wsURL += "/";
wsURL += hrefParts[i];
}
wsURL += "/_vti_bin/Webs.asmx";
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetAllSubWebCollection xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
</GetAllSubWebCollection > \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: wsURL,
beforeSend: function (xhr) {
xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetAllSubWebCollection");
},
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
error:function(xhr,err){
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
alert("responseText: "+xhr.responseText);
},
contentType: "text/xml; charset=\"utf-8\""
});
});
function processResult(xData, status) {
...
}
但是,由于 beforeSend 调用,我总是遇到登录问题。如果我将其注释掉,我会从 SharePoint 收到“拒绝访问”错误页面。 我对该站点和所有子站点具有“完全控制”权限。调用不同的 Web 服务(例如从 lists.asmx 调用 GetListCollection)成功。
这可能是什么问题?
【问题讨论】:
-
一些问题:保存 javascript 的页面在哪里?在某处的文档库中?登录问题是 401 Unauthorized 错误吗?
-
它在“页面”库中。现在问题已解决,如下面的答案所述。
标签: jquery sharepoint authentication web-services