Getting Authentication Prompt When Accessing SharePoint Web Services
You have a SharePoint site that is configured to be accessible by anonymous users, and the site's permissions are also configured to allow anonymous users.
You create a JavaScript based web part to access SharePoint's web services, pull list items, and display them using the GetListItems SOAP 1.2 call.
For some reason, users are prompted to authenticate when accessing your site.
I discovered that the fix for this is in the web request content type.
If you set the content type to "text/xml; charset=utf-8" as in the SOAP 1.1 envelope sample, SharePoint won't prompt you to authenticate.
Here's the /_vti_bin/lists.asmx?op=GetListItems output for reference:
SOAP 1.2
Here's some sample code to make a JavaScript call to SharePoint Web Services:
var soapEnvelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" +
"<soap12:Body>" +
"<GetListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" +
"<listName>OPR</listName>";
soapEnvelope = soapEnvelope.concat(
"</GetListItems>",
"</soap12:Body></soap12:Envelope>");
//using jQuery ajax to make the web request
$.ajax({
url: self.webUrl + "/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnvelope,
contentType: "text/xml; charset=\"utf-8\"" //"application/soap+xml; charset=\"utf-8\""
, async: false
}).done(function (data, textStatus, jqXHR) {
var rows = data.getElementsByTagName("z:row");
if (rows.length == 0) {
rows = data.getElementsByTagName("row");
}
for (var r = 0; r < rows.length; r++) {
var row = rows[r];
var ID = "";
var Title = "";
for (var a = 0; a < row.attributes.length; a++) {
var aname = row.attributes[a].name;
var avalue = row.attributes[a].value;
if (aname == "ows_ID") {
ID = avalue;
}
else if (aname == "ows_Title") {
Title = avalue;
}
} //end for attributes
$("#OutputDiv").html("Title: " + Title+"<br />");
} //end for rows
You create a JavaScript based web part to access SharePoint's web services, pull list items, and display them using the GetListItems SOAP 1.2 call.
For some reason, users are prompted to authenticate when accessing your site.
I discovered that the fix for this is in the web request content type.
If you set the content type to "text/xml; charset=utf-8" as in the SOAP 1.1 envelope sample, SharePoint won't prompt you to authenticate.
Here's the /_vti_bin/lists.asmx?op=GetListItems output for reference:
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.POST /_vti_bin/lists.asmx HTTP/1.1 Host: moss2007hv.kor.cmil.mil Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetListItems" <?xml version="1.0" encoding="utf-8"?> <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> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>string</listName> <viewName>string</viewName> <query> <xsd:schema>schema</xsd:schema>xml</query> <viewFields> <xsd:schema>schema</xsd:schema>xml</viewFields> <rowLimit>string</rowLimit> <queryOptions> <xsd:schema>schema</xsd:schema>xml</queryOptions> <webID>string</webID> </GetListItems> </soap:Body> </soap:Envelope>
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <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> <GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <GetListItemsResult> <xsd:schema>schema</xsd:schema>xml</GetListItemsResult> </GetListItemsResponse> </soap:Body> </soap:Envelope>
SOAP 1.2
POST /_vti_bin/lists.asmx HTTP/1.1 Host: moss2007hv.kor.cmil.mil Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>string</listName> <viewName>string</viewName> <query> <xsd:schema>schema</xsd:schema>xml</query> <viewFields> <xsd:schema>schema</xsd:schema>xml</viewFields> <rowLimit>string</rowLimit> <queryOptions> <xsd:schema>schema</xsd:schema>xml</queryOptions> <webID>string</webID> </GetListItems> </soap12:Body> </soap12:Envelope>
HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <GetListItemsResult> <xsd:schema>schema</xsd:schema>xml</GetListItemsResult> </GetListItemsResponse> </soap12:Body> </soap12:Envelope>
Here's some sample code to make a JavaScript call to SharePoint Web Services:
var soapEnvelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" +
"<soap12:Body>" +
"<GetListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" +
"<listName>OPR</listName>";
soapEnvelope = soapEnvelope.concat(
"</GetListItems>",
"</soap12:Body></soap12:Envelope>");
//using jQuery ajax to make the web request
$.ajax({
url: self.webUrl + "/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnvelope,
contentType: "text/xml; charset=\"utf-8\"" //"application/soap+xml; charset=\"utf-8\""
, async: false
}).done(function (data, textStatus, jqXHR) {
var rows = data.getElementsByTagName("z:row");
if (rows.length == 0) {
rows = data.getElementsByTagName("row");
}
for (var r = 0; r < rows.length; r++) {
var row = rows[r];
var ID = "";
var Title = "";
for (var a = 0; a < row.attributes.length; a++) {
var aname = row.attributes[a].name;
var avalue = row.attributes[a].value;
if (aname == "ows_ID") {
ID = avalue;
}
else if (aname == "ows_Title") {
Title = avalue;
}
} //end for attributes
$("#OutputDiv").html("Title: " + Title+"<br />");
} //end for rows
the blog is aboutAutomated data lineage documentation using #Dot Net it is useful for students and dot net Developers for more updates on dot net follow the link
ReplyDeleteDot Net Online Training Hyderabad
Smm Panel
ReplyDeletesmm panel
iş ilanları
İNSTAGRAM TAKİPÇİ SATIN AL
HIRDAVATÇI BURADA
beyazesyateknikservisi.com.tr
servis
Tiktok para hilesi
pendik samsung klima servisi
ReplyDeletebeykoz vestel klima servisi
tuzla vestel klima servisi
tuzla bosch klima servisi
tuzla arçelik klima servisi
çekmeköy samsung klima servisi
maltepe bosch klima servisi
kadıköy bosch klima servisi
kartal samsung klima servisi
uc satın al
ReplyDeletelisans satın al
en son çıkan perde modelleri
en son çıkan perde modelleri
nft nasıl alınır
özel ambulans
yurtdışı kargo
minecraft premium