.net – Why use wcf over web services on .net Compact Framework

compact-frameworknetwcfweb services

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.

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.

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)

Best Answer

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.

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.

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.

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.

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.

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.