小编DrE*_*ans的帖子

为SharePoint 2013创建跨平台移动应用程序

我想为我的SharePoint服务器制作一个简单的CRUD跨平台移动应用程序.我正在使用PhoneGap来处理跨平台编码 - 因此我的代码将使用HTML,CSS和JavaScript.

我遇到的主要障碍是使用我的SharePoint服务器进行身份验证.许多人在线都成功使用了AJAX调用,但是我收到以下错误:

XMLHttpRequest cannot load http://<DOMAIN>/_vti_bin/authentication.asmx. The request was redirected to 'http://<DOMAIN>/_layouts/15/error.aspx?ErrorText=Request%20format%20is%20unrecognized%2E', which is disallowed for cross-origin requests that require preflight. 
Run Code Online (Sandbox Code Playgroud)

以下是我的JavaScript代码:

function Authenticate() {
    $.support.cors = true;
    $.mobile.allowCrossDomainPages = true;

    $("#topnavcontent").append("Creating SOAP envelope...</br>");

    var soapEnv = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"     xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
    "<soap:Body>" +
    "<Login xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" +
    "<username>USERNAME</username>" +
    "<password>PASSWORD</password>" +
    "</Login>" +
    "</soap:Body>" +
    "</soap:Envelope>";

    $("#topnavcontent").append("Calling authenticate.asmx...</br>");

    $.ajax({
        url: "http://<DOMAIN>/_vti_bin/authentication.asmx",
        type: "POST",
        data: soapEnv,
        complete: authenticationResultSuccess,
        contentType: "text/xml; charset=\"utf-8\"",
        error: authenticationResultError
    });
}
Run Code Online (Sandbox Code Playgroud)

我知道浏览器正在发送一个飞行前OPTIONS调用.默认情况下,SharePoint网站不支持OPTIONS调用.是否有任何解决方法,例如禁用此OPTIONS调用或SharePoint站点上允许预先飞行的webconfig中的设置.在此先感谢您的帮助.

javascript sharepoint android cordova

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

标签 统计

android ×1

cordova ×1

javascript ×1

sharepoint ×1