Jaydata & Javascript noobie. I'm having problems with jaydata and basic authentication, can't seem to get it to work. I specify user and password but the headers never contains an auth line. Jaydata version is 1.3.6
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="/scripts/jquery-1.11.0.js"></script>
<script type="text/javascript" src="/scripts/datajs-1.0.3.js"></script>
<script type="text/javascript" src="/scripts/jaydata.js"></script>
<script type="text/javascript" src="/scripts/jaydataproviders/oDataProvider.js"></script>
<script type="text/javascript" src="/scripts/zawtst.js"></script>
<script>
var nwcontext = new ZAWTST_SRV.ZAWTST_SRV({
name: 'oData',
oDataServiceHost: 'http://vmerpd01.sap.int:8080/sap/opu/odata/sap/zawtst_srv',
user: "XXXXX",
password: "xxxxxxx"
});
function createItemLI(name, id, css) {
var li = $('<li></li>').append(name).addClass(css).data('id', id);
return li;
}
$(function () {
nwcontext.SalesOrderCollection.toArray(function (SalesOrderCollection) {
SalesOrderCollection.forEach(function (category) {
$('#categories').append(
createItemLI(SalesOrder.SdDoc, SalesOrder.Material, 'category'));
});
});
});
</script>
</head>
<body>
<ul id="categories">
</ul>
</body>
When testing in Chrome, I see no auth line:
Remote Address:10.1.8.171:8080
Request URL:http://vmerpd01.sap.int:8080/sap/opu/odata/sap/zawtst_srv/SalesOrderCollection
Request Method:OPTIONS
Status Code:401 Unauthorized
Request Headers -----------------------
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:accept, maxdataserviceversion, dataserviceversion, authorization
Access-Control-Request-Method:GET
Cache-Control:max-age=0
Connection:keep-alive
Host:vmerpd01.sap.int:8080
Origin:http://10.8.0.6:8080
Referer:http://10.8.0.6:8080/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
Response Headers --------------------
content-encoding:gzip
content-length:947
content-type:text/html; charset=utf-8
sap-system:GD1
www-authenticate:Basic realm="SAP NetWeaver Application Server [GD1/400]"
Yet here in the javascript console I can see the auth line.
Exception {name: "HTTP request failed", message: "", data: Arguments[1], stack: (...), _getStackTrace: function}
data: Arguments[1]
0: Object
message: "HTTP request failed"
request: Object
callbackParameterName: "$callback"
data: undefined
enableJsonpCallback: false
formatQueryString: "$format=json"
headers: Object
Accept: "application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1"
Authorization: "Basic WFhYWFg6eHh4eHh4eA=="
DataServiceVersion: "2.0"
MaxDataServiceVersion: "2.0"
__proto__: Object
Any thoughts ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…