简体   繁体   English

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

[英]Creating a Cross-Platform Mobile Application for SharePoint 2013

I want to make a simple CRUD Cross-Platform Mobile Application for my SharePoint server at work. 我想为我的SharePoint服务器制作一个简单的CRUD跨平台移动应用程序。 I'm using PhoneGap to deal with the cross-platform coding - as a result my code will be in HTML, CSS, and JavaScript. 我正在使用PhoneGap来处理跨平台编码 - 因此我的代码将使用HTML,CSS和JavaScript。

The main roadblock I have had is authenticating with my SharePoint server. 我遇到的主要障碍是使用我的SharePoint服务器进行身份验证。 Many people online have successfully used AJAX calls, however I receive the following error: 许多人在线都成功使用了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. 

The following is my JavaScript code: 以下是我的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
    });
}

I understand the browser is sending a pre-flight OPTIONS call. 我知道浏览器正在发送一个飞行前OPTIONS调用。 The SharePoint site by default does not support OPTIONS calls. 默认情况下,SharePoint网站不支持OPTIONS调用。 Is there any workaround for this, such as disabling this OPTIONS call or a setting in the webconfig on the SharePoint site that will allow the pre-flight through. 是否有任何解决方法,例如禁用此OPTIONS调用或SharePoint站点上允许预先飞行的webconfig中的设置。 Thanks in advance for the help. 在此先感谢您的帮助。

The Office 365 APIs are designed to be used against Mobile Apps and Standalone Web Applications. Office 365 API旨在用于移动应用程序和独立Web应用程序。 More details here: http://msdn.microsoft.com/en-us/library/office/dn605892(v=office.15).aspx 更多细节在这里: http//msdn.microsoft.com/en-us/library/office/dn605892(v = office.15).aspx

Once you have authenticated with Azure AD with the new Office 365 APIs, you can actually use the SharePoint CSOM and REST APIs with the auth bearer. 使用新的Office 365 API对Azure AD进行身份验证后,您实际上可以将SharePoint CSOM和REST API与身份验证承载一起使用。

Have you checked out the Cordova (PhoneGap) project type in Visual Studio 2013? 您是否在Visual Studio 2013中检出了Cordova(PhoneGap)项目类型? This generates js files when you do Add Connections n the project node in Solution Explorer to connect to the Office 365 APIs. 当您在解决方案资源管理器中的项目节点添加连接以连接到Office 365 API时,这将生成js文件。

Very shortly we'll have code samples of the WoodGrove App that was demoed at MS TechEd NA Keynote in http://www.github.com/OfficeDev . 很快,我们将在http://www.github.com/OfficeDev上的MS TechEd NA Keynote上演示WoodGrove App的代码示例。

There is currently native Android samples using this API via the Android SDK here https://github.com/OfficeDev/Office-365-SDK-for-Android 目前通过Android SDK使用此API的原生Android示例https://github.com/OfficeDev/Office-365-SDK-for-Android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM