c# - Consume soap web service with Xamarin.droid

i'm using xamarin studio to build my first android app, to consume a web service and i can't find any help in the documentation : Click here!.

I tried to watch some videos, all i found is about xamarin.forms

Upvotes: 1

Views: 3699

Answers (1)

Sergio Ramirez
Sergio Ramirez

Reputation: 340

You must import the web reference as a .NET 2.0 Web Services if your service is not a WCF service:

Step 1

step 2

Calling the service:

        Button button = FindViewById<Button> (Resource.Id.myButton);

        button.Click += delegate {
            SoapApp.www.webservicex.net.GlobalWeather soapservice = new SoapApp.www.webservicex.net.GlobalWeather();
            var cities = soapservice.GetCitiesByCountry("peru");
            button.Text = cities;
        };

this is the result:

Result

If it doesn't work try to do that building the proxy in Visual Studio in a new project and them copying the class to the Xamarin Studio project, i know it isn't the best way to do it but is a workaround.

Dont forget to add the System.Web.Services and System.ServiceModel references.

Sorry for the spanish verions of Xamarin Studio, hope it helps you

Upvotes: 1

Related Questions