c# - 使用 Xamarin.droid 使用 soap web 服务

c# - Consume soap web service with Xamarin.droid

我正在使用 xamarin studio 构建我的第一个 android 应用程序,以使用网络服务,但我在文档中找不到任何帮助: 点击 here!。

我试着看了一些视频,我发现的都是关于 xamarin.forms

如果您的服务不是 WCF 服务,则必须将 Web 引用导入为 .NET 2.0 Web 服务:

调用服务:

        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;
        };

这是结果:

如果它不起作用,请尝试在新项目的 Visual Studio 中构建代理,然后将 class 复制到 Xamarin Studio 项目,我知道这不是最好的方法,但它是一种解决方法。

不要忘记添加 System.Web.ServicesSystem.ServiceModel 引用。

很抱歉 Xamarin Studio 的西班牙文版本,希望它对您有所帮助