繁体   English   中英

使用Android Xamarin消费网络服务

[英]Consuming web service with android xamarin

我已经构建了一个应用程序:单击按钮,然后从HelloWorld()中给出一句话。 我已将Web服务放在IIS上,并且运行良好。 当我将“ localhost”更改为我的IPv4地址时,可以在浏览器和仿真器上访问Web服务。 一切正常。 但是,当我部署该应用程序时,它会返回以下异常:ConnectionFailure(连接被拒绝)。 你知道如何解决这个问题吗? 我将我的Web服务添加为Web参考。 我不知道为什么它仍然无法工作。 已经被卡了两个星期了。 请帮我。 非常感谢。

这是我的代码,连接到Android应用中的Web服务:

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();

            };

        }

这是模拟器中的Web服务

我在学习时就使用Xamarin网站上的教程。 这里看一下本教程,看看是否有帮助。 我必须提到我正在使用WCF。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM