Consume WCF Service in Windows Phone application: methods return void

半世苍凉 提交于 2019-12-24 08:49:59

问题


I have WCF service

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.


回答1:


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);


来源:https://stackoverflow.com/questions/19616958/consume-wcf-service-in-windows-phone-application-methods-return-void

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!