I've added the webreference in the Xamarin.Android App, then I instantiate it in the code like that:
WebReference.WebServiceEmp service = new WebReference.WebServiceEmp();
var data = service.HelloWorld();
But it throws:
System.Net.WebException: Error: ConnectFailure (Connection timed out)
When I add the service reference in Console Application instantiateing it like that:
ServiceReference1.WebServiceEmpSoapClient
service= new ServiceReference1.WebServiceEmpSoapClient();
DataTable data = service.Add();
It works fine. Why it doesn't work in Xamarin Android app? (I added the reference url like that: http://(myIp):8092/WebServiceEmp.asmx)
Or else refer this tutorial
https://bsubramanyamraju.blogspot.in/2017/04/xamarinforms-consuming-rest-webserivce_17.html
Answers
I you are checking in emulator then make sure your emulator is having internet and in your android properties have you given internet permission.
Check your emulator by browsing any web site in emulator's browser if it is not navigating then issue with emulator
I'm using real device connected to the PC via USB cable.
Check whether you have given internet permission in project android properties
Yes. I put that in AndroidManifest
Yes. I put that in AndroidManifest
First you can check for internet by using below codition
if (NetworkCheck.IsInternet())
and you can check for web service status code by
below condition
if (response.IsSuccessStatusCode)
Or else refer this tutorial
https://bsubramanyamraju.blogspot.in/2017/04/xamarinforms-consuming-rest-webserivce_17.html