.net – Visual Studio/SOAP – ‘Add Service Reference’ vs ‘Add Web Service Reference’

netsoapvisual studiowcfweb services

I've found that I can import a SOAP/WSDL service that I plan on using into my solution either as a "Web Service Reference" (System.Web.Services) or as a "Service Reference" (System.ServiceModel / WCF).

I was wondering if what the differences were. I understand that 'Add Service Reference'/WCF is newer, are there any disadvantages to using it over System.Web.Services or is it now the preferred way of consuming SOAP services in .Net?

Best Answer

The preferred and most useful way is indeed to use Add Service Reference. This will add your service as WCF client side proxy.

Add Web Reference is the "old-style" ASMX/ASP.NET webservice way of doing things.

WCF is the much better choice than ASMX, because:

  • it's newer and will be supported in the future (ASMX is on the way out); if you learn it now, you won't have to learn it later when ASMX is definitely gone
  • it offers much more flexibility in every aspect
  • you can only ever host an ASMX service is IIS, using HTTP as your protocol; WCF can be hosted in IIS; self-hosted in a Windows NT Service; WCF can use HTTP, NetTCP, MSMQ and many more protocols
  • WCF offers a lot more security and other settings, making it much more powerful to use

Yes, WCF has a bad rap about being really hard to learn - I don't really find that to be true. Check out those beginner's resources - very useful indeed!