DrE*_*ans 5 javascript sharepoint android cordova
我想为我的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中的设置.在此先感谢您的帮助.
Office 365 API 旨在用于移动应用程序和独立 Web 应用程序。更多详细信息请参见:http://msdn.microsoft.com/en-us/library/office/dn605892 (v=office.15).aspx
使用新的 Office 365 API 通过 Azure AD 进行身份验证后,您实际上可以将 SharePoint CSOM 和 REST API 与身份验证承载一起使用。
您是否检查过 Visual Studio 2013 中的 Cordova (PhoneGap) 项目类型?当您在解决方案资源管理器中的项目节点中执行“添加连接”以连接到 Office 365 API 时,这会生成 js 文件。
很快我们就会获得 WoodGrove 应用程序的代码示例,该示例已在http://www.github.com/OfficeDev的 MS TechEd NA 主题演讲中进行了演示。
目前有通过 Android SDK 使用此 API 的本机 Android 示例https://github.com/OfficeDev/Office-365-SDK-for-Android
| 归档时间: |
|
| 查看次数: |
1033 次 |
| 最近记录: |