Difference between Web Reference and Service Reference

by Raju Maharjan 2. December 2010 16:38

Visual Studio provides Web references. Web references differ from traditional references and components; instead of referencing a component or a class library installed on the local computer, a Web reference provides access to a resource that is available using an Internet protocol such as SOAP or HTTP.  Web reference is a generated proxy class that locally represents the exposed functionality of an XML Web service. Web Reference allows you to communicate with any service based on any technology that implements the WS-I Basic Profile 1.1, and exposes the relevant metadata (WSDL). Internally, it uses the ASMX communication stack on the client side. Add Web Reference is a wrapper over wsdl.exe and can be used to create proxies for .NET 1.1 or 2.0 clients. Of course this means when you are pointing to a WCF service you have to be pointing to an endpoint that uses basicHttpBinding.

A Service Reference allows you to communicate with any service based on any technology that implements any of the many protocols supported by WCF (including but not limited to WS-I Basic Profile). Internally, it uses the WCF communication stack on the client side. Add Service Reference is a wrapper over svcutil.exe and also creates clients proxies (and additionally web.config entries). These proxies, however, can only be consumed by .NET 3.0+ clients.If you are working with a WCF service application and the project contains a handful of simple data contracts, then you possibly won't encounter any problem in using the Add Service Reference feature of Visual Studio to generate service proxies. However, there might come a time when you need to use inheritance or circular references in your data contracts. In these cases, creating service proxies manually might be a better option than using the Add Service Reference dialog.

It is perfectly possible (though not recommended) to add a Web Reference that points to a WCF service, as long as the WCF endpoint uses basicHttpBinding or some compatible custom variant.

Below image will show you how to add web reference from Service Reference. Right click the Service References from solution explorer, then select advance button on Add Services window you will get to the form as in below image and then will be able to add Web Reference via Add web Reference window.

Difference between Web Reference and Service Reference

It is also possible to add a Service Reference that points to an ASMX service. When writing new code, you should always use a Service Reference simply because it is more flexible and future-proof.

 

Tags: ,

WCF | Web Services

Comments

12/14/2010 4:28:45 PM #

http://www.articlesbash.com

I've been writing about this topic on my site. I'm nearly complete with the post I just needed to do some more research before finishing it. Your post helped me to understand more aspects so thank you. I'll digg your site! Come over and browse my site. Thanks!

http://www.articlesbash.com United States | Reply

Add comment


() (Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading




Sapnep IT Solution

We Provide IT solutions and services to deliver a unique blend of real-business experience with a strong engineering, international project delivery. We are a software development  firm.