Hi,
I need to get some data using soap xml http request, but the response always shows "Error code 400 received: Bad Request".
Who can tell me what's wrong with my js code which is as follows?
Any help or pointer to same would be appreciated. Regards.
Code:function sendRequest(){ var symbol = "MSFT"; var xmlhttp = new XMLHttpRequest(); xmlhttp.open("POST", "http://www.webservicex.net/stockquote.asmx?op=GetQuote", true); xmlhttp.setRequestHeader("SOAPAction", "http://www.webserviceX.NET/GetQuote"); xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { if (xmlhttp.responseText != null) { alert(xmlhttp.responseText); } else { alert("Failed to receive RSS file from the server - file not found."); return false; } } else { alert("Error code " + xmlhttp.status + " received: " + xmlhttp.statusText); // error here } } else { alert("Error ready state " + xmlhttp.readyState); } } 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); }

Reply With Quote

