C# 使用android xamarin消费web服务

C# 使用android xamarin消费web服务,c#,android,web-services,soap,xamarin,C#,Android,Web Services,Soap,Xamarin,我已经建立了一个应用程序:点击按钮,然后它会给出一个来自HelloWorld()的句子。我已经将我的web服务放在IIS上,它工作得很好。当我将“localhost”更改为IPv4地址时,我也可以在浏览器和模拟器上访问web服务。一切正常。但当我部署应用程序时,它会返回异常:ConnectionFailure(连接被拒绝)。你知道如何解决这个问题吗?我将我的web服务添加为web引用。我不知道为什么它仍然不能工作。已经被困了两周了。请帮帮我。非常感谢 这是我在Android应用程序中连接到web

我已经建立了一个应用程序:点击按钮,然后它会给出一个来自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();

            };

        }
protectedoverride void OnCreate(捆绑包)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
Button Button=FindViewById(Resource.Id.MyButton);
TextView txt=findviewbyd(Resource.Id.textView1);
按钮。单击+=委派
{
WebReference.websv connect=新的WebReference.websv();
connect.Url=”http://192.168.xxx.xxx/tigonkhung.com/websv.asmx";
txt.Text=connect.HelloWorld();
};
}

我在学习时使用了Xamarin网站上的教程。看看这个教程,看看它是否有用。我必须提到的是,我当时正在使用WCF。

仍然在使用“asmx”?好好休息吧,你的生活会轻松得多。