I want to make a simple CRUD Cross-Platform Mobile Application for my SharePoint server at work. I'm using PhoneGap to deal with the cross-platform coding - as a result my code will be in HTML, CSS, and JavaScript.
The main roadblock I have had is authenticating with my SharePoint server. Many people online have successfully used AJAX calls, however I receive the following error:
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:
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. The SharePoint site by default does not support OPTIONS calls. 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. Thanks in advance for the help.
I want to make a simple CRUD Cross-Platform Mobile Application for my SharePoint server at work. I'm using PhoneGap to deal with the cross-platform coding - as a result my code will be in HTML, CSS, and JavaScript.
The main roadblock I have had is authenticating with my SharePoint server. Many people online have successfully used AJAX calls, however I receive the following error:
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:
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. The SharePoint site by default does not support OPTIONS calls. 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. Thanks in advance for the help.
0 commentaires:
Enregistrer un commentaire