【问题标题】:Consume WCF Service in Windows Phone application: methods return void在 Windows Phone 应用程序中使用 WCF 服务:方法返回 void
【发布时间】:2019-02-07 22:13:49
【问题描述】:

我有 WCF 服务

当我在我的 Windows Phone 应用程序中“添加服务引用”时,一切看起来都很好,但方法返回 void。例如,我在 WPF 应用程序中测试了这个服务器,它可以工作并返回我需要的东西,但在 wp 7/8 应用程序中没有。当然,这个 WCF 的基本功能是返回数据,所以 void 方法对我来说完全没用。

【问题讨论】:

    标签: wcf windows-phone


    【解决方案1】:

    您可以使用AsyncCompleted 事件服务。服务将在completed 事件中返回数据,如

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

    【讨论】:

    • 我已经做到了,谢谢,但谁能告诉我为什么在 WPF 应用程序中异步方法返回值,但在 windows phone 应用程序(7 或 8)中添加服务引用会生成 void 方法:(?跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-14
    • 1970-01-01
    • 2010-10-25
    • 1970-01-01
    相关资源
    最近更新 更多