在Windows Phone应用程序中使用WCF服务:方法返回void

在Windows Phone应用程序中使用WCF服务:方法返回void,wcf,windows-phone,Wcf,Windows Phone,我有WCF服务 当我在我的windows phone应用程序中“添加服务引用”时,一切看起来都很好,但方法返回无效。例如,我在WPF应用程序中测试了这个服务器,它可以工作并返回我需要的内容,但在WP7/8应用程序中没有。当然,此WCF的基本功能是返回数据,因此无效方法对我来说完全没有用处。您可以使用serviceAsync和Completed事件。service将在Completed事件中返回数据 ServiceReference1.Service1Client clientForTesting

我有WCF服务


当我在我的windows phone应用程序中“添加服务引用”时,一切看起来都很好,但方法返回无效。例如,我在WPF应用程序中测试了这个服务器,它可以工作并返回我需要的内容,但在WP7/8应用程序中没有。当然,此WCF的基本功能是返回数据,因此无效方法对我来说完全没有用处。

您可以使用service
Async
Completed
事件。service将在
Completed
事件中返回数据

ServiceReference1.Service1Client clientForTesting = new ServiceReference1.Service1Client();
            clientForTesting.GetDataCompleted += new EventHandler<ServiceReference1.GetDataCompletedEventArgs>(TestCallback);
            clientForTesting.GetDataAsync(testValue);
ServiceReference1.Service1Client-fortesting=newservicereference1.Service1Client();
clientForTesting.GetDataCompleted+=新事件处理程序(TestCallback);
GetDataAsync(testValue);

我已经这样做了,谢谢,但是谁能告诉我为什么在WPF应用程序中异步方法返回值,而在windows phone应用程序(7或8)中,添加服务引用生成无效方法:(?