Error Consuming .net Webservice(asmx) from Android Xamarin(VS2015)

i have created a web service in VS2015. My web service is having a function SignUpUser it will take 3 parameter and returns result in integer.

 MyFirstWebService.Service Serv = new MyFirstWebService.Service();
 int result = Serv.SignUpUser("abc", "password", "[email protected]");

am calling the above code from button click event of VS2015(Xamarin Android) but it is giving me the error as below

system.net.webexception error connectfailure (connection refused)
at system.net.sockets.socketexception:connection refused
at system.net.webconnection.connect(system.net.httpwebrequest request)

I have checked so many links, everywhere mentioned instead of localhost use 10.0.2.2 http://localhost:58614/Service.asmx but am not clear. i have
tested my webservice with C# windows application its working without any issue. Did i missed anything particularly?? i could not find proper example for the asmx webservice. :(

Answers

  • CheesebaronCheesebaron DKInsider, University mod

    I suggest you use something with a RESTFul API instead.

  • SelvaTSelvaT USMember

    Hi,
    Thanks for your time
    Can I know what's the drawback of using asmx webservice in Android ?

  • CheesebaronCheesebaron DKInsider, University mod

    If you really want to use ASP.NET then use the Web API to create a web service.

Sign In or Register to comment.