当前位置:首 页 > 攻城湿 >Windows Phone > 查看文章

Windows Phone动态调用Webservice

Windows Phone 你是第2354个围观者 3条评论 供稿者: 标签:, ,

网上的一些Windows Phone调用WebService的教程大多数都是通过”添加服务引用”来做,万一WebService的地址改变了就很麻烦,这几天查了很多资料,终于在WP里实现了动态调用WebService的方法。
1.命令提示符进行目录C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Tools。
2.运行SlSvcUtil http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx就可以生成MobileCodeWS.cs的代理类。
3.把这个类引用到WP8的项目。
4.调用

string url = @"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";
System.ServiceModel.BasicHttpBinding theBinding = new System.ServiceModel.BasicHttpBinding();
theBinding.MaxReceivedMessageSize = int.MaxValue;
theBinding.MaxBufferSize = int.MaxValue;

MobileCodeWSSoapClient wsClient = new MobileCodeWSSoapClient(theBinding, new System.ServiceModel.EndpointAddress(url));
wsClient.getMobileCodeInfoCompleted += (s, arg) =>
                {
                    if (arg.Error != null)
                    {
                        this.txtTip.Text = "执行错误!";
                        return;
                    }
                    this.txtTip.Text = arg.Result;
                };
            wsClient.getMobileCodeInfoAsync("123456789", "");
这家伙很懒,什么都没写!

—— zhaorong

zhaorong
你可能也喜欢Related Posts
众说纷纭Comments
大眼 可爱 大笑 坏笑 害羞 发怒 折磨 快哭了 大哭 白眼 晕 流汗 困 腼腆 惊讶 憨笑 色 得意 骷髅 囧 睡觉 眨眼 亲亲 疑问 闭嘴 难过 淡定 抗议 鄙视 猪头
小提示:直接粘贴图片到输入框试试
努力发送中...
  1. 1 楼 UFO

    拜访,谢谢博主分享!欢迎来小站坐坐!

    2013年07月15日 05:00:33 回复 取消回复
  2. 2 楼 包包网

    期待您的回访!

    2013年07月24日 06:53:37 回复 取消回复
  3. 3 楼

    捧腹网是中国领先的笑话幽默分享网站,捧腹致力于打造一个分享各类欢乐内容的互动平台,让我们一起: “捧腹开怀、乐享人生”!牙膏夹心饼

    2014年01月19日 09:18:21 回复 取消回复
  • 评论最多
  • 最新评论
  • 随机文章
footer logo
未经许可请勿自行使用、转载、修改、复制、发行、出售、发表或以其它方式利用本网站之内容
Copyright © zhaorong All Rights Reserved. 滇ICP备15006105号-1