1
SOAP響應我試圖根據 Simplest SOAP example從服務器獲取
我可以通過這個代碼發送請求,但沒有來自服務器無響應,使SOAP調用。下面的示例代碼我給出:
輸入代碼在這裏
<html>
<head>
<title>SOAP call sample</title>
<script language="Javascript">
<!--
function xmlhttpPost() {
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("ready state callback:"+xmlhttp.readyState);
alert("response text or XML"xmlhttp.responseText);
var json = XMLObjectifier.xmlToJSON(xmlhttp.responseXML);
var result = json.Body[0].GetQuoteResponse[0].GetQuoteResult[0].Text;
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");
xmlhttp.setRequestHeader("POST","/stockquote.asmx HTTP/1.1");
xmlhttp.setRequestHeader("Host","www.webservicex.net");
xmlhttp.setRequestHeader("Content-Length",1000);
alert("setrequest header completed");
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);
alert("request sent"+xmlhttp);
}
//-->
</script>
</head>
<form name="main">
<table>
<tr>
<td> <input value="Submit to eBay => " type="button"
onclick='JavaScript:xmlhttpPost()'></td>
<td><textarea name="eBayXMLResponse" wrap="soft" rows="40" cols="50" style="overflow:scroll" ID="Textarea1"></textarea></td>
</tr>
</table>
</form>
</html>
我通過月食嘗試這個樣品與動態Web項目,並通過Apache,Tomcat的7.0.25運行應用程序server.Is這足夠運行該樣品? 請幫我在瀏覽器控制檯中顯示響應。 我在這個問題上掙扎了一週.....請讓我知道是否有人對此有所瞭解。
也許你需要在客戶端和服務器之間的數據包捕獲,看看發生了什麼。 – ciphor 2012-03-04 09:46:39
嗨ciphor,請告訴我清楚得到SOAP響應需要什麼? – Mahes 2012-03-04 09:57:00
有多種可能的原因,1.請求未發出; 2.服務器不工作; 3.回覆不發送;數據包捕獲將幫助您澄清您遇到的情況。 – ciphor 2012-03-04 11:58:49