在 Windows Phone 应用程序中使用 WCF 服务:方法返回无效 [英] Consume WCF Service in Windows Phone application: methods return void

查看:28
本文介绍了在 Windows Phone 应用程序中使用 WCF 服务:方法返回无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 WCF 服务

当我在 Windows Phone 应用程序中添加服务引用"时,一切看起来都不错,但方法返回无效.例如,我在 WPF 应用程序中测试了该服务器,它可以工作并返回我需要的内容,但在 wp 7/8 应用程序中则不然.当然这个 WCF 的基本功能是返回数据,所以 void 方法对我来说完全没用.

When I "Add Service Reference" in my windows phone application everything looks good but methods return void. I tested this server for example in WPF app and it works and returns what I need but in wp 7/8 app not. Ofcourse the basic functionality of this WCF is to return data so void methods are totally useless for me.

推荐答案

您可以使用服务 AsyncCompleted 事件.服务将在 completed<中返回数据/code> 事件如

You can use service Async and Completed events.Service will return data in completed event like

ServiceReference1.Service1Client clientForTesting = new ServiceReference1.Service1Client();
            clientForTesting.GetDataCompleted += new EventHandler<ServiceReference1.GetDataCompletedEventArgs>(TestCallback);
            clientForTesting.GetDataAsync(testValue);

这篇关于在 Windows Phone 应用程序中使用 WCF 服务:方法返回无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆