简体   繁体   English

如何从智能设备应用程序对WCF服务进行异步调用?

[英]How to make an Asynchronus call to WCF service from a smart device application?

I am developing a smart device application, which is going to communicate with a wcf service over wi-fi. 我正在开发一个智能设备应用程序,它将通过wi-fi与wcf服务进行通信。 As there is no option to add a service reference into a smart device project I decided to use the NetCFSvcUtil.exe. 由于无法选择将服务引用添加到智能设备项目中,因此我决定使用NetCFSvcUtil.exe。 Everything works great! 一切正常!

But... 但...

In the end I understood that the application must interact with the service in the background. 最后,我了解到应用程序必须在后台与服务交互。 Having read this article Microsoft .NET Compact Framework Background Processing Techniques . 阅读过本文Microsoft .NET Compact Framework后台处理技术 I decided to use the Asynchronous Web Service Call. 我决定使用异步Web服务调用。 There http://msdn.microsoft.com/ru-ru/library/aa347733.aspx I found the /async parameter, but it appeared to not work for the NetCFSvcUtil.exe. http://msdn.microsoft.com/ru-ru/library/aa347733.aspx上,我找到了/ async参数,但它似乎不适用于NetCFSvcUtil.exe。

What can I do to get the async proxy for my smart device application? 如何为我的智能设备应用程序获取异步代理? Is there a way to generate it or I'm expected to add async methods to the interface with my own hands? 有没有一种生成它的方法,或者我希望自己动手向接口添加异步方法? Maybe it would be suitable for .Net CF to use SvcUtil.exe to generate the async proxy in my case? 在我的情况下,.Net CF使用SvcUtil.exe生成异步代理也许合适?

A further more information like which platform you are using to build your Smart phone application would be helpful. 进一步的信息(如正在使用哪个平台来构建智能手机应用程序)将很有帮助。

I have done Blackberry development and consumed web services. 我已经完成了Blackberry开发并消耗了Web服务。 There are two ways you could build your web services 有两种方法可以构建Web服务

  1. RestFul Service - Consumption of web services would be pretty easy. RestFul服务-使用Web服务非常简单。 Posting data could be a little pain as multipart form data is posted as stream in Wcf - Rest Starter Kit 在Wcf中将多部分表单数据作为流发布时,发布数据可能会有些痛苦-Rest Starter Kit

  2. Soap Service - If you decide to use SOAP, then for blackberry and Android you have to use preverified KSOAP -2 to send and receive soap messages between your app and the web service. 肥皂服务-如果您决定使用SOAP,那么对于黑莓和Android,您必须使用预先验证的KSOAP -2在应用程序和Web服务之间发送和接收肥皂消息。 If you decide to use KSOAP -2 , go back ASMX services. 如果决定使用KSOAP -2,请返回ASMX服务。 Somehow WCF services does not communicate with KSOAP -2 (due to change in SOAP version or something) where as a simple ASMX service works pretty smoothly. WCF服务以某种方式无法与KSOAP -2通信(由于SOAP版本或其他方面的更改),在此情况下,简单的ASMX服务可以非常顺利地工作。 There are dozens of article which you could use to learn how to use KSOAP 您可以使用许多文章来学习如何使用KSOAP。

he original idea was to host it in a windows service... 他最初的想法是将其托管在Windows服务中...

Windows Services could never be web facing. Windows服务永远不会面向Web。 If you want any thing to be web facing, you need a Web Server ! 如果您想让任何东西都面向Web,则需要一台Web服务器!

In the end it worked. 最后,它奏效了。 The "Add web reference" tool created a proxy with Begin/End async methods and the proxy interacted with the wcf service hosted by a simple console application (later a windows service) through the URL property of the proxy. “添加Web参考”工具使用Begin / End异步方法创建了一个代理,并且该代理通过该代理的URL属性与由简单控制台应用程序(后来称为Windows服务)托管的wcf服务进行了交互。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM