windows-phone-7 – 如何在Windows Phone 7中调用webservice方法
发布时间:2020-12-14 05:53:37 所属栏目:Windows 来源:网络整理
导读:为了连接到webservices,我编写了以下代码. WebClient wc = new WebClient();wc.DownloadStringAsync(new Uri("http://www.Webservices.asmx"));wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);void wc
为了连接到webservices,我编写了以下代码.
WebClient wc = new WebClient(); wc.DownloadStringAsync(new Uri("http://www.Webservices.asmx")); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); void wc_DownloadStringCompleted(object sender,DownloadStringCompletedEventArgs e) { Debug.WriteLine("Web service says: " + e.Result); using (var reader = new StringReader(e.Result)) { String str = reader.ReadToEnd(); } } 通过使用上面的代码获取字符串结果.但我想在HTMLVisulaizer中获得结果然后我知道有什么方法有webservice.then我可以轻松访问特定的方法. 请提前告诉我. 解决方法
@Jason James
第一步: 你必须添加参考服务,就像杰森詹姆斯有非常详细的说明. 第2步 : 您可以在Functions Apps中打开App.xaml.cs public Apps() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode,// which shows areas of a page that are being GPU accelerated with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; } // You can declare objects here that you will use //Examlpe: NameservicesReferent.(Function that returns services) = new NameservicesReferent.(Function that returns services)(); Ws_Function = new Nameservices.ServiceSoapClient(); } 第3步: 在Mainpage.xaml.cs中 GlobalVariables.Ws_advertise.getLinkAdvertiseIndexCompleted += new EventHandler<advertise.getLinkAdvertiseIndexCompletedEventArgs>(Ws_advertise_getLinkAdvertiseIndexCompleted); GlobalVariables.***NameWedservise***.getLinkAdvertiseIndexAsync("**parameters to be passed**"); 第4步: void Ws_advertise_getLinkAdvertiseIndexCompleted(object sender,advertise.getLinkAdvertiseIndexCompletedEventArgs e) { //function returns the results to you,the example here is an array string[] array = null; try { array = e.result; if(array != null) } cath(exception ex) { } finally { array = null; GlobalVariables.Ws_advertise.getLinkAdvertiseIndexCompleted -= new EventHandler<advertise.getLinkAdvertiseIndexCompletedEventArgs>(Ws_advertise_getLinkAdvertiseIndexCompleted); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows 7 改造
- windows – cygwin curl,Wget,wget和top“命令未找到”
- 使用window.opener在IE中的JavaScript问题
- iis-7 – 必须运行IISRESET两次才能启动所有与IIS相关的服务
- 如何在vbscript中播放Windows播放器中的所有歌曲?
- Windows上的nginx停止/重新加载失败,因为Access被拒绝
- 如何判断Windows内核事件对象是自动重置还是手动重置?
- windows – 阻止手动睡眠的SetThreadExecutionState
- 在windows和linux上编译
- WiX:避免显示正在使用的文件对话框,只是在安装结束时提示重
推荐文章
站长推荐
热点阅读