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.

Please help me to find the problem.

//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);
}
Simon MacDonald
  • 23,253
  • 5
  • 58
  • 74

1 Answers1

1
  • Replace "localhost:5020" with your local(private) ip-address "192.168.x.x:5020", Your AVD will connect to on machine dev web-server. Do a ip-config/all on windows or ifconfig on linux distros to know ur local-ip.

    android emulator and local site

Community
  • 1
  • 1
nuthan
  • 465
  • 2
  • 5
  • 19
  • First of all I was completely wrong in using localhost in my code. Basically the server is sitting in a diferent location ( IP:10.225.20.15 ) I am trying to access that server from a another system. Anyway, I have tried by replacing localhost by the above IP address it's not working for me. – user1315030 Apr 06 '12 at 08:04
  • @user1315030 this worked for me, the AVD n web server on same machine. Am not sure how to approach AVD on ur server on diff machine. May be this might help u [emulator network devices](http://developer.android.com/guide/developing/devices/emulator.html#networkaddresses)! – nuthan Apr 07 '12 at 10:32
  • Did you try the same code in same machine ? If it is working then I will definitely try to work with client and server in same system. Thanks a lot for your valuable information's Nuthan. – user1315030 Apr 08 '12 at 19:05
  • @user1315030 yeah my AVD and web-server were on same host... I also tried on different machine, it worked!!! – nuthan Apr 10 '12 at 13:19
  • I have tried from different machine with system ip and 10.0.2.15:5020 as decribed in Android Emulator network setup configuration by google. Both are not working. Could you please tell me how to setup for different machine? – user1315030 Apr 11 '12 at 12:47
  • R u able to open any links from the emulator browser? – nuthan Apr 12 '12 at 06:29
  • No. Could you please tell me how to configure. – user1315030 Apr 12 '12 at 11:22
  • Have you set the internet permission in your AndroidManifest.xml ` ` – nuthan Apr 12 '12 at 11:59
  • Regarding webservice, it's a TIBCO environment at back end and SOAP service is exposed to client.I am using PhoneGap tool for development. permissions are there in Manifest file.Still it's not giving any response but if I run from IE it's giving proper response. – user1315030 Apr 17 '12 at 04:43
  • Not sure whats a TIBCO environment. Perhaps this might help you... check this http://stackoverflow.com/questions/2039964/how-to-connect-android-emulator-to-the-internet – nuthan Apr 17 '12 at 05:22