我正在使用 Amadeus Web 服务创建一个网站。我创建了一个 SOAP 并使用 SOAP UI 进行了测试。我得到了完整的答复。之后,我尝试在网络浏览器中获得响应。然后我创建了一个以下文件。但是,当我输入所有数据并单击“搜索”按钮时,它给了我这 2 个错误 -
选项https://noded1.test.webservices.amadeus.com/XXXXX 500(其他错误)无法加载 https://noded1.test.webservices.amadeus.com/XXXXX:预检响应包含无效的 HTTP 状态代码 500。
我该如何修复这些错误?
这是PHP文件。
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="http://www.timestampgenerator.com/js/common.js"></script>
</head>
<body>
<form class="form-horizontal" method="POST" action="#" enctype="multipart/form-data" id="signupForm">
<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
Message Id : <input class="form-control" id="messageid" type="text" placeholder="Results will be placed here..." readonly size="40"/> <br>
</div>
<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
Nonce : <input class="form-control" id="nonceshow" type="text"/> <br>
</div>
<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
Timestamp : <input class="form-control" type="text" name="timestampama" id="timestampama"/> <br>
</div>
<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
Text : <input type="text" class="form-control" name="strex" id="strex" size="20" /> <br>
</div>
<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
SHA-1 : <input type="text" class="form-control" name="strcrypt" id="strcrypt" size="33" /> <br>
</div>
<a href="#" id="ghsubmitbtn" class="btn btn-success">Search</a>
<p id="errorModal"></p> <br>
<div id="ghapidata" class="clearfix"></div>
</form>
<p id="body"></p>
<script type="text/javascript">
//Main Function
$(document).ready(function () {
$.getScript("PwJs.js", function () {
});
$('#ghsubmitbtn').on('click', function(e) {
var country = $('#country').val();
var year = $('#year').val();
var month = $('#month').val();
var messageid = guid();
//var nonce = nonceid();
//var nonceremove = nonce.slice(0, -4); //Remove last 4 characters
//var n = nonceremove.length; //Length
var pw = 'SSSSSS';
var str = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://xml.amadeus.com/2010/06/Security_v1" xmlns:typ="http://xml.amadeus.com/2010/06/Types_v1" xmlns:iat="http://www.iata.org/IATA/2007/00/IATA2010.1" xmlns:app="http://xml.amadeus.com/2010/06/AppMdw_CommonTypes_v3" xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1" xmlns:ses="http://xml.amadeus.com/2010/06/Session_v3" xmlns:fmp="http://xml.amadeus.com/FMPTBQ_14_3_1A">' +
'<soapenv:Header>' +
'<add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">' + messageid + '</add:MessageID>' +
'<add:Action xmlns:add="http://www.w3.org/2005/08/addressing">http://webservices.amadeus.com/ZZZZZ</add:Action>' +
'<add:To xmlns:add="http://www.w3.org/2005/08/addressing">https://nodeD1.test.webservices.amadeus.com/XXXXXX</add:To>' +
'<link:TransactionFlowLink xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1"/>' +
'<oas:Security xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">' +
'<oas:UsernameToken oas1:Id="UsernameToken-1" xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' +
'<oas:Username>WSEOLMTT</oas:Username>' +
'<oas:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">' + noncemove + '</oas:Nonce>' +
'<oas:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">' + hashedPw + '</oas:Password>' +
'<oas1:Created>' + timestampama + '</oas1:Created>' +
'</oas:UsernameToken>' +
'</oas:Security>' +
'<AMA_SecurityHostedUser xmlns="http://xml.amadeus.com/2010/06/Security_v1">' +
'<UserID AgentDutyCode="SU" POS_Type="1" PseudoCityCode="CMBI228AJ" RequestorType="U"/>' +
'</AMA_SecurityHostedUser>' +
'</soapenv:Header>' +
'<soapenv:Body>' +
'<Fare_MasterPricerTravelBoardSearch>' +
'<numberOfUnit xmlns="http://xml.amadeus.com/FMPTBQ_14_3_1A">' +
'<unitNumberDetail>' +
'<numberOfUnits>1</numberOfUnits>' +
'<typeOfUnit>PX</typeOfUnit>' +
'</unitNumberDetail>' +
'<unitNumberDetail>' +
'<numberOfUnits>250</numberOfUnits>' +
'<typeOfUnit>RC</typeOfUnit>' +
'</unitNumberDetail>' +
'</numberOfUnit>' +
'<paxReference>' +
'<ptc>ADT</ptc>' +
'<traveller>' +
'<ref>1</ref>' +
'</traveller>' +
'</paxReference>' +
'<fareOptions>' +
'<pricingTickInfo>' +
'<pricingTicketing>' +
'<priceType>ET</priceType>' +
'<priceType>TAC</priceType>' +
'<priceType>RP</priceType>' +
'</pricingTicketing>' +
'</pricingTickInfo>' +
'</fareOptions>' +
'<itinerary>' +
'<requestedSegmentRef>' +
'<segRef>1</segRef>' +
'</requestedSegmentRef>' +
'<departureLocalization>' +
'<departurePoint>' +
'<locationId>DEL</locationId>' +
'</departurePoint>' +
'</departureLocalization>' +
'<arrivalLocalization>' +
'<arrivalPointDetails>' +
'<locationId>BOM</locationId>' +
'</arrivalPointDetails>' +
'</arrivalLocalization>' +
'<timeDetails>' +
'<firstDateTimeDetail>' +
'<date>161018</date>' +
'</firstDateTimeDetail>' +
'</timeDetails>' +
'<flightInfo>' +
'<cabinId>' +
'<cabin>Y</cabin>' +
'</cabinId>' +
'</flightInfo>' +
'</itinerary>' +
'</Fare_MasterPricerTravelBoardSearch>' +
'</soapenv:Body>' +
'</soapenv:Envelope>';
//console.log(departureDate);
$.ajax({
url: 'https://nodeD1.test.webservices.amadeus.com/XXXXXX',
method: 'POST',
contentType:"text/xml; charset=utf-8",
data: str,
//headers: {"Authorization": 'Bearer ' + bat},
beforeSend: function (xhr) {
xhr.setRequestHeader('SOAPAction', 'http://webservices.amadeus.com/ZZZZZ');
},
success: function (data) {
console.log(data);
}
});
});
});
</script>
</body>
</html>
这是 JavaScript 文件。
//Nonce
function nonceid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var n = 0; n < 12; n++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return btoa(text).slice(0, -4);
}
var n = nonceid().length; //Length
var noncemove = nonceid();
console.log("Nonce - " +noncemove);
console.log("Nonce Characters - " +n);
document.getElementById('ghsubmitbtn').addEventListener('click', function() {
document.getElementById('nonceshow').value = nonceid();
})
//Timestamp
var timestampama = new Date().toISOString();
console.log("Timestamp - " +timestampama);
console.log(new Date());
document.getElementById('ghsubmitbtn').addEventListener('click', function() {
document.getElementById('timestampama').value = timestampama;
})
//register onclick events for Encrypt button
document.getElementById('ghsubmitbtn').addEventListener('click', function() {
document.getElementById('strcrypt').value = completepw;
})
/* document.getElementById('ghsubmitbtn').onclick = function() {
var txt_string = document.getElementById('strex').value; // gets data from input text
//encrypts data and adds it in #strcrypt element
document.getElementById('strcrypt').value = completepw;
console.log("SHA1 - " +SHA1(txt_string));
return false;
} */
//SHA1
function rotate_left(n,s) {
var t4 = ( n<<s ) | (n>>>(32-s));
return t4;
}
function lsb_hex(val) {
var str="";
var i;
var vh;
var vl;
for( i=0; i<=6; i+=2 ) {
vh = (val>>>(i*4+4))&0x0f;
vl = (val>>>(i*4))&0x0f;
str += vh.toString(16) + vl.toString(16);
}
return str;
}
function cvt_hex(val) {
var str="";
var i;
var v;
for( i=7; i>=0; i-- ) {
v = (val>>>(i*4))&0x0f;
str += v.toString(16);
}
return str;
}
function SHA1 (msg) {
function Utf8Encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
};
var blockstart;
var i, j;
var W = new Array(80);
var H0 = 0x67452301;
var H1 = 0xEFCDAB89;
var H2 = 0x98BADCFE;
var H3 = 0x10325476;
var H4 = 0xC3D2E1F0;
var A, B, C, D, E;
var temp;
msg = Utf8Encode(msg);
var msg_len = msg.length;
var word_array = new Array();
for( i=0; i<msg_len-3; i+=4 ) {
j = msg.charCodeAt(i)<<24 | msg.charCodeAt(i+1)<<16 |
msg.charCodeAt(i+2)<<8 | msg.charCodeAt(i+3);
word_array.push( j );
}
switch( msg_len% 4 ) {
case 0:
i = 0x080000000;
break;
case 1:
i = msg.charCodeAt(msg_len-1)<<24 | 0x0800000;
break;
case 2:
i = msg.charCodeAt(msg_len-2)<<24 | msg.charCodeAt(msg_len-1)<<16 | 0x08000;
break;
case 3:
i = msg.charCodeAt(msg_len-3)<<24 | msg.charCodeAt(msg_len-2)<<16 | msg.charCodeAt(msg_len-1)<<8 | 0x80;
break;
}
word_array.push( i );
while( (word_array.length% 16)!= 14 ) word_array.push( 0 );
word_array.push( msg_len>>>29 );
word_array.push( (msg_len<<3)&0x0ffffffff );
for ( blockstart=0; blockstart<word_array.length; blockstart+=16 ) {
for( i=0; i<16; i++ ) W[i] = word_array[blockstart+i];
for( i=16; i<=79; i++ ) W[i] = rotate_left(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1);
A = H0;
B = H1;
C = H2;
D = H3;
E = H4;
for( i= 0; i<=19; i++ ) {
temp = (rotate_left(A,5) + ((B&C) | (~B&D)) + E + W[i] + 0x5A827999) & 0x0ffffffff;
E = D;
D = C;
C = rotate_left(B,30);
B = A;
A = temp;
}
for( i=20; i<=39; i++ ) {
temp = (rotate_left(A,5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff;
E = D;
D = C;
C = rotate_left(B,30);
B = A;
A = temp;
}
for( i=40; i<=59; i++ ) {
temp = (rotate_left(A,5) + ((B&C) | (B&D) | (C&D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff;
E = D;
D = C;
C = rotate_left(B,30);
B = A;
A = temp;
}
for( i=60; i<=79; i++ ) {
temp = (rotate_left(A,5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff;
E = D;
D = C;
C = rotate_left(B,30);
B = A;
A = temp;
}
H0 = (H0 + A) & 0x0ffffffff;
H1 = (H1 + B) & 0x0ffffffff;
H2 = (H2 + C) & 0x0ffffffff;
H3 = (H3 + D) & 0x0ffffffff;
H4 = (H4 + E) & 0x0ffffffff;
}
var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4);
return temp.toUpperCase();
}
function SHA1Bytes (msg) {
var blockstart;
var i, j;
var W = new Array(80);
var H0 = 0x67452301;
var H1 = 0xEFCDAB89;
var H2 = 0x98BADCFE;
var H3 = 0x10325476;
var H4 = 0xC3D2E1F0;
var A, B, C, D, E;
var temp;
var msg_len = msg.length;
var word_array = new Array();
for( i=0; i<msg_len-3; i+=4 ) {
if (msg[i] > 255 || msg[i+1] > 255 || msg[i+2] > 255 || msg[i+3] > 255) alert('Not a byte!');
j = msg[i]<<24 | msg[i+1]<<16 |
msg[i+2]<<8 | msg[i+3];
word_array.push( j );
}
switch( msg_len% 4 ) {
case 0:
i = 0x080000000;
break;
case 1:
i = msg[msg_len-1]<<24 | 0x0800000;
break;
case 2:
i = msg[msg_len-2]<<24 | msg[msg_len-1]<<16 | 0x08000;
break;
case 3:
i = msg[msg_len-3]<<24 | msg[msg_len-2]<<16 | msg[msg_len-1]<<8 | 0x80;
break;
}
word_array.push( i );
while( (word_array.length% 16)!= 14 ) word_array.push( 0 );
word_array.push( msg_len>>>29 );
word_array.push( (msg_len<<3)&0x0ffffffff );
for ( blockstart=0; blockstart<word_array.length; blockstart+=16 ) {
for( i=0; i<16; i++ ) W[i] = word_array[blockstart+i];
for( i=16; i<=79; i++ ) W[i] = rotate_left(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1);
A = H0;
B = H1;
C = H2;
D = H3;
E = H4;
for( i= 0; i<=19; i++ ) {
temp = (rotate_left(A,5) + ((B&C) | (~B&D)) + E + W[i] + 0x5A827999) & 0x0ffffffff;
E = D;
D = C;
C = rotate_left(B,30);
B = A;
A = temp;
}
for( i=20; i<=39; i++ ) {
temp = (rotate_left(A,5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff;
E = D;
D = C;
C = rotate_left(B,30);
B = A;
A = temp;
}
for( i=40; i<=59; i++ ) {
temp = (rotate_left(A,5) + ((B&C) | (B&D) | (C&D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff;
E = D;
D = C;
C = rotate_left(B,30);
B = A;
A = temp;
}
for( i=60; i<=79; i++ ) {
temp = (rotate_left(A,5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff;
E = D;
D = C;
C = rotate_left(B,30);
B = A;
A = temp;
}
H0 = (H0 + A) & 0x0ffffffff;
H1 = (H1 + B) & 0x0ffffffff;
H2 = (H2 + C) & 0x0ffffffff;
H3 = (H3 + D) & 0x0ffffffff;
H4 = (H4 + E) & 0x0ffffffff;
}
var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4);
return temp.toUpperCase();
}
var gHexa = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64Bytes(input) {
var output = '';
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
while (i < input.length) {
chr1 = input[i++];
chr2 = input[i++];
chr3 = input[i++];
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
}
return output;
}
function parseHexaBytes(iText) {
var aResult = [];
for (var i=0; i < iText.length; i = i+2)
{
var aValue = parseInt(iText.substr(i, 2), 16);
//if (aValue > 255) alert('Too large!');
//if (aValue == 0) alert('Null value!');
aResult.push(aValue);
}
return aResult;
}
function stringToArray(iText) {
var aResult = [];
for (var i=0; i < iText.length; i = i+1)
{
aResult.push(iText.charCodeAt(i));
}
return aResult;
}
var pw = 'SSSSS';
var clearpw = 'AAAAA';
//Verify SHA1
var noncee = 'WnMwUUlVSkQ=';
var timestampamae = '2018-08-28T09:24:10:030Z';
var pwe = '123';
var shapwe = noncee+ ' + ' +timestampamae+ ' + ' +pwe; //5 + 6 + 123
// Base64 ( SHA-1 ( nonce + created + SHA-1 ( password ) ) )
var shapw = noncemove+ ' + ' +timestampama+ ' + ' +pw;
console.log("SHA1 Pw - " +SHA1(shapw));
console.log("SHA1Bytes Pw - " +SHA1Bytes(shapwe));
var completepw = btoa(SHA1(shapw));
console.log("Comple Pw - " +completepw);
var completepwWithAma = btoa(encode64Bytes(shapwe));
console.log("Complete Pws Ama Code - " +completepwWithAma);
function WbsPassword(clearpw,timestampama,noncemove) {
var aPwd = parseHexaBytes(SHA1(clearpw));
var aNonce = decode64Bytes(noncemove);
var aTime = stringToArray(timestampama);
var aHash = SHA1Bytes(aNonce.concat(aTime.concat(aPwd)));
var HshPwd = encode64Bytes(parseHexaBytes(aHash));
return HshPwd;
}
var hashedPw = WbsPassword(clearpw,timestampama,noncemove);
console.log(WbsPassword("WbsPassword - " +clearpw,timestampama,noncemove));
console.log("hashedPw - " +hashedPw);