views:

346

answers:

3

I see that there are two options that I know can be used in web services... WCF obviously, and ASP.NET Web Services. What's the difference? I just started picking up WCF recently and had a little exposure to web services in the past, but I'm certainly not an expert.

+1  A: 

ASP.NET web services was Microsoft's first attempt at web services.

WCF replaces ASP.NET web servies and .NET remoting. WCF provides a common programming model that enables you to do what the two older technologies where capable of and much more including support for a wide range of protocols and security models.

Go with WCF if you have the choice.

Jakob Christensen
A: 

ASP.NET webservices is OKAY - but it's limited to HTTP hosted in IIS only, and has other problems.

WCF supports way more transport protocols (HTTP in various ways, TCP, MSMQ and more), has a lot richer security model (credentials, federated security), and offer options for hosting - self-hosting in a Windows app or service, in IIS or WAS and more.

In short: if you're starting now - go learn WCF by all means !

Marc

marc_s
+5  A: 

it is quite easy to know the differences.

ASP.NET Web Method is called ASMX [because of the file extension] (check 4GuysFromRolla about this, they have a good tutorial)

This technology makes you expose methods as a Web Service so you can connect it (to the WS) from everywhere and use it (the methods). But... you can't protect the data between server and client, like, you can send big files in a clear mode, etc...

[Note] you can protect the access to the web service using certificates, but it is a pain and quite complicated, normally in ASMX we use username / passsword to give access to a method (once again... in plain text!)

In WCF, you are in the different world about Web Services, and this is the best technology in .NET (so far) to expose Services (can you see the difference... Services! not Web Services), WCF does not need IIS to run, it can run as a System Service on the server, using a console ambient (like command line), in TCP/IP mode, etc, so we say that WCF is a Service, not a Web Service. Remember ASMX need IIS to run and will only run hosted in a Web Server.

With WCF you can use SSL to encrypt the communication (to do that in ASMX you need to use WSE - Web Services Enhancements) and it is quite easy to implement it, you can send big files and securely (to do that in ASMX you need to use MTOM - Message Transmission Optimization Mechanism).

you can set the transmission preferences just changing one line of code, or even, if you prefer, change the XML configuration file, the security is much higher, etc, etc :)

hope you get a better general overview with this, but there is much more.

bottom line: to expose Web Services that you do not need to protect, you can use ASMX, no problem at all, but if you need to protect the communication somehow, do it in WCF!

link: you can read here some performance comparative between the 2 services

balexandre
So If I'm developing a web site, that has different layers/tiers - data, service, web - with the service layer being a WCF service stack communicating with the data layer, and in my web layer I want to use jQuery for things such as autocomplete, it's fine to just use web services that ultimately call through to WCF Services? And if I want to secure the data, it should go through HTTPS? Is my understanding correct. (I'm new to .net in general, done Java stuff before)
jamiebarrow
To make my example a bit clearer, all I require from the web client side is the ability to retrieve JSON using AJAX. I already have an ASP.NET AJAX web tier, speaking to a WCF tier. I only want the browser to talk to the web tier.
jamiebarrow