2017-02-27 82 views
0

我已經構建了一個應用程序:單擊該按鈕,然後從HelloWorld()中發出一個句子。我已將我的Web服務放在IIS上,並且運行良好。當我將「localhost」更改爲我的IPv4地址時,我也可以訪問瀏覽器和仿真器上的Web服務。一切工作正常。但是,當我部署應用程序時,它會返回異常:ConnectionFailure(連接被拒絕)。你知道如何解決這個問題嗎?我將我的Web服務添加爲Web參考。我不知道爲什麼它仍然無法工作。已經堅持了2周。請幫幫我。非常感謝。使用android xamarin使用web服務

這是我的代碼連接到Web服務在Android應用:

protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 
      SetContentView(Resource.Layout.Main);    
      Button button = FindViewById<Button>(Resource.Id.MyButton); 
      TextView txt = FindViewById<TextView>(Resource.Id.textView1); 
      button.Click += delegate 
      { 
       WebReference.websv connect = new WebReference.websv(); 
       connect.Url = "http://192.168.xxx.xxx/tigonkhung.com/websv.asmx"; 
       txt.Text = connect.HelloWorld(); 

      }; 

     } 

This is the web service in the emulator

+0

仍在使用「asmx」?去休息吧,你的生活會容易得多。 –

回答

0

我用Xamarin網站上的教程當我學習。看看這個教程here看看是否有幫助。我必須提到,我使用的是WCF。