2

I'm consuming webservices developed by a third party and I noticed some differences in its behaviour depending on how I add them to the VS project: Add Service Reference or Add Web Reference.

From what I've researched, a service added by Add Service Reference is more recent and suited for WCF services. Since I don't know what kind of services are the ones I'm trying to interact with, is there a way I can know which is the better way to add them?

I get a little better behaviour when I add them by Add Web Reference and so I'm tempted to use it for every service but I really don't know.

Note: I've checked this post too.

Community
  • 1
  • 1
chiapa
  • 4,362
  • 11
  • 66
  • 106

1 Answers1

1

Check link here. I think this has already been answered in the link.

A 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 as WSDL. Internally, it uses the ASMX communication stack on the client's side.

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.

Note that both these definitions are quite wide, and both include services not written in .NET.

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.

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.

Community
  • 1
  • 1
Rex
  • 1,134
  • 15
  • 26
  • Thanks. I've checked the answer of [Christian Hayter](http://stackoverflow.com/users/115413/christian-hayter) in that [question](http://stackoverflow.com/questions/308454/difference-between-web-reference-and-service-reference) and you shouldn't be copying it but referring to it instead. Anyway, it gives a theoretical view but not a specific answer for my question. – chiapa May 30 '14 at 08:09