2

我正在创建一个需要同步 Web 服务调用的 xamarin 表单应用程序。但只有 GetAsync 以 xamarin 形式提供。谁能解释一下如何以 xamarin 形式调用同步 Web 服务调用?

4

1 回答 1

1

尝试这样的事情

public Webservice() { }
public Home GetHome()
{
    string strpost = "";
    var client = new System.Net.Http.HttpClient();
    client.BaseAddress = new Uri(" xyz ");
    var response = client.PostAsync(new Uri(" xyz "), str).Result;
    var result = JsonConvert.DeserializeObject<Home>(response.Content.ReadAsStringAsync().Result);
    Home home = new Home();
    if (!Equals(result, null))
    {
        home = result;
        return home;
    }
}

参考:https ://forums.xamarin.com/discussion/43397/how-to-call-synchronous-webservice

于 2015-11-23T11:13:53.143 回答