我正在创建一个xamarin表单的应用程序,它需要同步的web服务调用。但只有GetAsync是可用的xamarin形式。有人能解释一下如何用xamarin表单调用同步web服务吗?
发布于 2015-11-23 11:13:53
试试像这样的东西
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
https://stackoverflow.com/questions/33868358
复制相似问题