Reputation: 495
I'm developing an application on Android, I'm trying to use it to connect to a SQL Server 2005 database through a webservice.
I have the webservice accessing the database and tested on it's own.
Now I have the code to connect to the webservice from android, but, I'm getting a "connection refused" error whenever I try to test it.
I put the URL of the webservice as it appears on the ASP test server: private static final String URL = "http://localhost:3068/Service1.asmx";
I suspect this is the issue, how does the Android simulator know what localhost is, but, how do I resolve this?
Upvotes: 0
Views: 590
Reputation: 4328
Because you're running Android in a VM, 'localhost' refers to the actual IP of the VM.
What you should do is find out what other IP addresses are assigned to the PC and use that.
I used the one supplied by my LAN 192.168.x.x . You can find out what yours is using ipconfig /all.
SideNote: If you're trying to use SOAP webservices you're in for a shock because they're not supported very well on Android. Look for "REST" services and save yourself the trouble.
Upvotes: 0
Reputation: 4196
I assume the ASP test server is running on the same system as the database - which means you can use http://localhost:3068/Service1.asmx
. But is your android simulaor running n that system or somewhere else. If somewhere else, you will hav eto supply a full URL - something like http://www.mysqlserver.com:3068/Service1.asmx
.
Upvotes: 0
Reputation: 4370
You need to replace localhost with the server name or IP address of the server you are attempting to connect to.
Upvotes: 2