0
I have a SOAP service in my local system. I have implimented the Java Script code and tested in internet browser, it's working fine but the same code I am using for android application development using phoneGap, I am not getting any response from Android simulator.
請幫我找到問題。在使用phoneGap訪問SOAP服務時沒有收到Android模擬器的任何響應
//Function called in button click.
function getEmpDetails() {
var e_id = $("#empID").val();
alert("e_id :"+e_id);
var url = "http://localhost:5020/EmployeeService";
var envelope = "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'xmlns:inp='http://InputMessageNamespace'>";
envelope += "<soap:Header/>";
envelope += "<soap:Body>";
envelope += "<inp:EmployeeDetailsOperation>";
envelope += "<EmployeeId>"+e_id+"</EmployeeId>";
envelope += "</inp:EmployeeDetailsOperation>";
envelope += "</soap:Body>";
envelope += "</soap:Envelope>";
$.ajax({
url: url,
type: "POST",
dataType: "xml",
contentType: "text/xml;charset=UTF-8",
data: envelope,
beforeSend: function(xhr) { xhr.setRequestHeader("SOAPAction", "/Process Definition"); },
success: OnSuccess,
error: OnError
});
};
function OnSuccess(data, status)
{
alert(status);
alert(data.xml);
}
function OnError(request, status, error)
{
alert('error');
}
function init() {
alert("init");
document.addEventListener("deviceready", deviceInfo, true);
}
首先我是在我的代碼使用本地主機完全錯誤的。基本上服務器坐在不同的位置(IP:10.225.20.15)我試圖從另一個系統訪問該服務器。無論如何,我已經嘗試通過上面的IP地址替換本地主機,它不適合我。 – user1315030 2012-04-06 08:04:48
@ user1315030這適用於我,同一臺機器上的AVD n web服務器。我不確定如何在diff服務器上使用AVD。可能是這可能會幫助你[模擬器網絡設備](http://developer.android.com/guide/developing/devices/emulator.html#networkaddresses)! – nuthan 2012-04-07 10:32:47
你在同一臺機器上試過相同的代碼嗎?如果它正在工作,那麼我一定會嘗試在同一個系統中使用客戶端和服務器。非常感謝您的有價值的信息Nuthan。 – user1315030 2012-04-08 19:05:52