我正在创建一个需要同步Web服务调用的xamarin表单的应用程序。但只有GetAsync可用于xamarin表单。有谁能请解释我如何调用xamarin表单中的同步Web服务调用?
答案 0 :(得分: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