WszystkieWiele żądań SOAP przy użyciu kodu JavaScript
Używam mojego interfejsu SOAP API przy użyciu skryptu Java.
ten przykład wyjaśnić, jak wysłać prośbę jednego mydła używając js
var symbol = "MSFT";
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://www.webservicex.net/stockquote.asmx?op=GetQuote",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4) {
alert(xmlhttp.responseText);
// http://www.terracoder.com convert XML to JSON
var json = XMLObjectifier.xmlToJSON(xmlhttp.responseXML);
var result = json.Body[0].GetQuoteResponse[0].GetQuoteResult[0].Text;
// Result text is escaped XML string, convert string to XML object then convert to JSON object
json = XMLObjectifier.xmlToJSON(XMLObjectifier.textToXML(result));
alert(symbol + ' Stock Quote: $' + json.Stock[0].Last[0].Text);
}
}
xmlhttp.setRequestHeader("SOAPAction", "http://www.webserviceX.NET/GetQuote");
xmlhttp.setRequestHeader("Content-Type", "text/xml");
var xml = '<?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> ' +
'<GetQuote xmlns="http://www.webserviceX.NET/"> ' +
'<symbol>' + symbol + '</symbol> ' +
'</GetQuote> ' +
'</soap:Body> ' +
'</soap:Envelope>';
xmlhttp.send(xml);
// ...Include Google and Terracoder JS code here...
Teraz chcę wysłać wielokrotne żądania SOAP w czasie (średnio więcej niż jeden wniosek kopertę).
Nic nie powinno powstrzymywać Cię przed wysłaniem kolejnego żądania ('new XMLHttpRequest()') zaraz po tym. Jest to wysyłanie asynchroniczne. – namuol
to jest problem http://stackoverflow.com/questions/6922058/what-is-wrong-this-js-got-this-error-cannot-use-object-of-type-stdclass-as-ar –
hai i używam twojego kodu, ale xmlhttp.responseText ma wartość null. – user969275