2015-11-23 73 views

回答

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

+0

謝謝你這麼多 – gunas

+0

嗨,你有我的web服務調用需要很長時間來執行任何想法。 – gunas

+0

@gunas,它更好地使用異步 - 等待方法。或者完美的方法是儘早打電話給你的網絡服務。 – Vaikesh