为什么在.net Compact Framework上使用wcf而不是Web服务?

时间:2021-08-05 16:51:04

Let us assume I'm using communicating from my mobile device to my server via WCF web service. I could also do this with a standard web service as well.

我们假设我正在使用通过WCF Web服务从我的移动设备与我的服务器进行通信。我也可以使用标准的Web服务来完成这项工作。

I have read the WCF Guidance for Mobile Developers (http://wcfguidanceformobile.codeplex.com/), the only thing I see there is WCF has SSL support while straight web services do not.

我已经阅读了WCF移动开发人员指南(http://wcfguidanceformobile.codeplex.com/),我唯一看到的是WCF具有SSL支持,而直接Web服务则没有。

Now, a valid reason might be you have multiple device TYPES (desktop, web, server-to-server, etc) you want to use to communicate with the server using different protocols -- I don't have that need. I just need to talk to my server from a mobile device (.netcf)

现在,一个有效的原因可能是你有多个设备类型(桌面,网络,服务器到服务器等),你想用它们使用不同的协议与服务器通信 - 我没有这个需要。我只需要通过移动设备(.netcf)与我的服务器通话

2 个解决方案

#1


John is correct that ASMX web services are now considered a legacy technology. In general, when writing code that communicates with other processes over any sort of network, your default choice should be WCF.

John是正确的,ASMX Web服务现在被认为是传统技术。通常,在编写通过任何类型的网络与其他进程通信的代码时,您的默认选择应该是WCF。

When you work with the full .NET framework (i.e. on servers and desktops), this is always true. There may be times when you need to use another technology (e.g. raw sockets), but never ASMX.

当您使用完整的.NET框架(即在服务器和桌面上)时,这始终是正确的。有时您可能需要使用其他技术(例如原始套接字),但从不使用ASMX。

WCF on .NET CF is different. It is a very limited port of WCF, and there are actually things you can do with the old web client that you can't do with WCF on .NET CF: In the old web client, you can use Windows Authentication with both HTTP and HTTPS. With WCF on .NET CF, you can only use Windows Authentication with HTTPS. That particular issue actually stopped us from using WCF on the device for Microsoft Dynamics Mobile.

.NET CF上的WCF是不同的。它是一个非常有限的WCF端口,实际上你可以使用旧的Web客户端做的事情,你不能用.NET CFCF上的WCF:在旧的Web客户端,你可以使用Windows身份验证与HTTP和HTTPS。使用.NET CFCF上的WCF,您只能使用带有HTTPS的Windows身份验证。该特定问题实际上阻止我们在Microsoft Dynamics Mobile设备上使用WCF。

There's a reason for this limitation, since you should never use Windows Authentication with HTTP in production scenarios, as the username and password will be transmitted in clear text, but we needed it for testing purposes.

这种限制是有原因的,因为您不应该在生产场景中使用带有HTTP的Windows身份验证,因为用户名和密码将以明文形式传输,但我们需要它用于测试目的。

With the risk of stating the obvious, I'd also like to point out that whatever decision you take with regards to the code you will be writing for your devices, you should definitely go with WCF if you also write the web services with which the devices will communicate.

由于存在明显的风险,我还想指出,无论您为将要为您的设备编写的代码做出什么决定,如果您还编写了与之相关的Web服务,那么您肯定应该使用WCF。设备将进行通信。

Even if you use the old web client technology on .NET CF, you can still talk to WCF services. That's what we did with Dynamics Mobile.

即使您在.NET CF上使用旧的Web客户端技术,您仍然可以与WCF服务进行通信。这就是我们使用Dynamics Mobile所做的。

#2


One reason is that Microsoft now considers ASMX Web Services a “Legacy Technology”.

一个原因是微软现在认为ASMX Web服务是一种“遗留技术”。

#1


John is correct that ASMX web services are now considered a legacy technology. In general, when writing code that communicates with other processes over any sort of network, your default choice should be WCF.

John是正确的,ASMX Web服务现在被认为是传统技术。通常,在编写通过任何类型的网络与其他进程通信的代码时,您的默认选择应该是WCF。

When you work with the full .NET framework (i.e. on servers and desktops), this is always true. There may be times when you need to use another technology (e.g. raw sockets), but never ASMX.

当您使用完整的.NET框架(即在服务器和桌面上)时,这始终是正确的。有时您可能需要使用其他技术(例如原始套接字),但从不使用ASMX。

WCF on .NET CF is different. It is a very limited port of WCF, and there are actually things you can do with the old web client that you can't do with WCF on .NET CF: In the old web client, you can use Windows Authentication with both HTTP and HTTPS. With WCF on .NET CF, you can only use Windows Authentication with HTTPS. That particular issue actually stopped us from using WCF on the device for Microsoft Dynamics Mobile.

.NET CF上的WCF是不同的。它是一个非常有限的WCF端口,实际上你可以使用旧的Web客户端做的事情,你不能用.NET CFCF上的WCF:在旧的Web客户端,你可以使用Windows身份验证与HTTP和HTTPS。使用.NET CFCF上的WCF,您只能使用带有HTTPS的Windows身份验证。该特定问题实际上阻止我们在Microsoft Dynamics Mobile设备上使用WCF。

There's a reason for this limitation, since you should never use Windows Authentication with HTTP in production scenarios, as the username and password will be transmitted in clear text, but we needed it for testing purposes.

这种限制是有原因的,因为您不应该在生产场景中使用带有HTTP的Windows身份验证,因为用户名和密码将以明文形式传输,但我们需要它用于测试目的。

With the risk of stating the obvious, I'd also like to point out that whatever decision you take with regards to the code you will be writing for your devices, you should definitely go with WCF if you also write the web services with which the devices will communicate.

由于存在明显的风险,我还想指出,无论您为将要为您的设备编写的代码做出什么决定,如果您还编写了与之相关的Web服务,那么您肯定应该使用WCF。设备将进行通信。

Even if you use the old web client technology on .NET CF, you can still talk to WCF services. That's what we did with Dynamics Mobile.

即使您在.NET CF上使用旧的Web客户端技术,您仍然可以与WCF服务进行通信。这就是我们使用Dynamics Mobile所做的。

#2


One reason is that Microsoft now considers ASMX Web Services a “Legacy Technology”.

一个原因是微软现在认为ASMX Web服务是一种“遗留技术”。