0
votes

I downloaded sample, went through tutoral for "Consume an ASP.NET Web Service (ASMX)" in Xamarin forms at https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/web-services/asmx. If I run from visual studio the web service runs in browser all good. If I make the android app the startup project it runs but does not get the todo items from service. I have made fire wall rule, modified the Consume an ASP.NET Web Service (ASMX), and creating a self-signed development certificate on your machine.

What I am stuck on is how to configure your project to use the appropriate HttpClient network stack for your debug build. For more information, see Configure your project.

https://docs.microsoft.com/en-us/xamarin/cross-platform/deploy-test/connect-to-local-web-services#configure-your-project

where does the following code go? And do i change my port to 49178 in code below?

//Device class public static string BaseAddress = Device.RuntimePlatform == Device.Android ? "https://10.0.2.2:5001" : "https://localhost:5001"; public static string TodoItemsUrl = $"{BaseAddress}/api/todoitems/";

1
port is usually after host ... so you have to change 5001 also you have to use emulator because obviosuly 10.0.2.2 nor localhost will not work on real deviceSelvin
I am running project and it is sending it to emulator it just isn't hitting the webservice or throwing error!Jonathan Conley
it just isn't hitting the webservice or throwing error! we don't know about it - it's not in the question ... also if you are getting some error it's worth to include them in the questionSelvin
I will simplify Android application runs in debug, ASMX Soap service runs in debug. But does not communicate between themselves. Like sample picture shows by showing todo items!Jonathan Conley
is your webserver setup to allow external connections? Have you verified that your Android device/emulator can connect to the server? Are you getting any exceptions or errors? This is most likely a networking/connectivity issue.Jason

1 Answers

0
votes
        //The solution I found was to ignore Microsoft's 
         // tutorial and publish web service to local IIS

                    //change constants.cs

            namespace TodoASMX
                {
                    public static class Constants
                    {
                        // URL of ASMX service
                        public static string SoapUrl
                        {
                            get
                            {
                                var defaultUrl = "http://192.168.254.25/TodoService.asmx";
                                //var defaultUrl = "http://localhost:49178/TodoService.asmx";

                                if (Device.RuntimePlatform == Device.Android)
                                {
                                    // defaultUrl = "http://10.0.2.2:49178/TodoService.asmx";
                                    defaultUrl = "http://192.168.254.25/TodoService.asmx";
                                }

                                //Also in references.cs

                                public TodoService()
                                {
                                    //  this.Url = "http://localhost:49178/TodoService.asmx";
                                    this.Url = "http://192.168.254.25/TodoService.asmx";


                                    // and also in properties window of web reference

                                    //Times like these I really despise Microsoft!!!