Доступ к списку разделяемых доменов между поддоменами - PullRequest
2 голосов
/ 06 марта 2012

Я пытаюсь получить доступ к данным списка из neighbour.domain.com , используя Javascript на home.domain.com .Оба - Sharepoint 2007.

Я использую код из ответ на этот вопрос .

$(function(){
    var soapEnv = 
    "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
        <soapenv:Body> \
            <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                <listName>Documents</listName> \
                <viewFields> \
                    <ViewFields> \
                        <FieldRef Name='Title' /> \
                    </ViewFields> \
                </viewFields> \
            </GetListItems> \
        </soapenv:Body> \
     </soapenv:Envelope>";
    $.ajax({
        url: "http://neighbor.domain.com/sites/site1/_vti_bin/lists.asmx",
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        contentType: "text/xml; charset=\"utf-8\"",
        complete: function(xData, status){
            $(xData.responseXML).find("z\\:row").each(function(){
                var title = $(this).attr("ows_FileLeafRef").split("#")[1];
                alert(title);
            })
        },
        error: function(){
            alert("error");
        }
    });
});

Это не работает для меня.Я получаю сообщение об ошибке: Доступ запрещен .
Я добавил jQuery.support.cors = true, но мне тоже не повезло.

Что-то мне не хватает?Требуется ли реализовать что-либо в другом домене ( neighbour.domain.com )?

У меня нет административного доступа к серверам (только доступ разработчика к Sharepoint).У меня есть доступ только для чтения к соседу .domain.com .

ОБНОВЛЕНИЕ (10 июля 2013 г.) : у меня более, чем доступ на чтение к соседу.domain.com .Мое решение заключалось в добавлении файла на другой поддомен, который извлекал бы данные списка на основе переданных ему параметров URL.

Ответы [ 2 ]

0 голосов
/ 10 июля 2013

Мое возможное решение заключалось в добавлении файла, который выполнял роль прокси-сервера для извлечения данных на neighbour.domain.com , с использованием Javascript.

Сценарий на neighbour.domain.com :

document.domain = 'domain.com';  // Important, so that both pages are considered
                                 // the same domain.  Allows us to access the
                                 // parent object when this page is loaded in an
                                 // iframe on the same domain.

// Returns value of URL parameter
function getURLParameter(name) { ... }    

// Retrieves URL parameters that tell the proxy what to do
// The Web services operation to call
var operation = getURLParameter("operation");
// The URL path of the site (i.e. /sites/sitename)
var weburl = getURLParameter("weburl");
// The name of the list on the site
var listname = getURLParameter("listname");

// Run the requested web service operation
if (operation === "GetListItems") {
  $().SPServices({
    operation: operation,
    listName: listname,
    webURL: weburl,
    completefunc: function (xData, Status) {
      // parent is a defined object when this page is loaded in an iframe on the
      // same domain.  The parent must have a 'passListItemsData' function
      // defined.
      parent.passListItemsData(xData.responseXML);
    }
  });
}
// Add more operations (and recognized URL params) as needed
else if (...) {...}

Вызов скрипта на home.domain.com :

document.domain = 'domain.com';  // Important, so that both pages are considered
                                 // the same domain.  Allows the proxy page to
                                 // access functions defined on this page.

// Create an iframe that makes a request of the proxy file using URL parameters
var iframe = document.createElement("iframe");
iframe.style.display = "none";
iframe.src = "neighbor.domain.com/path/proxyfile.html?operation=GetListItems&" + 
             "weburl=/sitepath/sitename&listname=name";
document.body.appendChild(iframe);  // Requests proxy page and kicks off the
                                    // process

/**
 * Implements the passListItemsData function for the subdomain proxy.  This
 * handles the results of a GetListItems function on the other subdomain.
 * @param data, results returned by the GetListItems Lists web service function
 */
function passListItemsData(data) {
  // Handle returned XML data from GetListItems web service
}
0 голосов
/ 06 марта 2012

Попробуйте мой ответ на этот вопрос.Это проще :) Это здесь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...