119

I just hit a huge brick wall with Paypal. I had created a regular C# project to create some wrapper classes using their WSDL.

If you create a non-web project, the only option you get to add a wsdl is a Web Service Reference. And this builds kinda the same set of proxy classes as a Web Reference would but not really..it adds more that even the PayPal guys are not aware of.

So I was this entire time looking for the right Interface in this list of proxy classes to use as the service (SoapBinding) and the PayPalAPIAASoapBinding was not there I kept telling our PayPal point in contact.

I could only see the following 2 Interfaces that appeared to me what I needed to use since I did not see a PayPalAPIAASoapBinding which you CAN see in a Web Reference based service reference:

PayPalAPIAAInterfaceClient
PayPalAPIInterfaceClient 

So I figured out oh, I probably had created a Service Reference vs. a Web Reference which Web Reference is an option in a Web project. But I don't want my service reference tightly coupled to my web project. So that's why I created the C# Project.

So what the heck is a Service Reference vs. Web Reference? And how am I supposed to separate this out into anther project if Service Reference is going to throw me a loop and give me a set of different interfaces than a Web Reference would?

Also, to make things even MORE confusing, VS 2008 has a Web Service Application project.

So what do I use? We're using the .NET 3.5 framework and we're not ready to move to WCF. So can I still use the new Service Reference even if not using WCF or what? IF you're using .NET 3.5 and not WCF yet and you still want to do basic web services, do you still go the Service Reference route and just not use the WCF framework? Meaning can it be used like a .NET 2.0 Web Reference still, just that you're going to get an entirely different generation of the WSDL?

PositiveGuy
  • 46,620
  • 110
  • 305
  • 471

4 Answers4

223

Add Web Reference is the old-style, deprecated ASP.NET webservices (ASMX) technology (using only the XmlSerializer for your stuff) - if you do this, you get an ASMX client for an ASMX web service. You can do this in just about any project (Web App, Web Site, Console App, Winforms - you name it).

Add Service Reference is the new way of doing it, adding a WCF service reference, which gives you a much more advanced, much more flexible service model than just plain old ASMX stuff.

Since you're not ready to move to WCF, you can also still add the old-style web reference, if you really must: when you do a "Add Service Reference", on the dialog that comes up, click on the [Advanced] button in the button left corner:

alt text

and on the next dialog that comes up, pick the [Add Web Reference] button at the bottom.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 6
    How stupid is that for MS to hide that in a WCF dialog box! Doesn't even make any sense with the placement here – PositiveGuy Jan 29 '10 at 16:27
  • 9
    @coffeeaddict: well, I think MS is trying to subtly sway you towards using WCF by default - and only old-style ASMX if you're really determined :-) – marc_s Jan 29 '10 at 16:34
  • 28
    If you use Alt + PrtScn you can take a snap shot of just the current active window, that way you won't have to manually crop out just what you want shown :o) – Ernest May 30 '13 at 15:58
  • Will that require .NET 2.0 too on the computer? Or .NET 4.0 will be able to handle the .NET 2.0 based "Web Reference" technology? I want to know because I am deploying a SOAP webservice as "Web Reference" in a .NET 4.0 application. – Computer User May 06 '14 at 21:07
  • Is this still valid as of 2017? – sparkyShorts Jan 06 '17 at 20:23
  • 1
    @sparkyShorts: yes. – marc_s Jan 07 '17 at 07:37
  • So does it mean I can create a wcf client from a web service by adding the web service as a service reference? A wcf client doesn't have to consume a wcf service? I have to consume a web service (not wcf) written by another team, what's the benefit of adding it as service reference over web reference? – dragonfly02 Feb 09 '17 at 21:36
  • Is the new WCF Web Service Reference Provider the same thing as the old Service Reference? – Vale Trujillo Jul 16 '20 at 18:25
9

If I understand your question right:

To add a .net 2.0 Web Service Reference instead of a WCF Service Reference, right-click on your project and click 'Add Service Reference.'

Then click "Advanced.." at the bottom left of the dialog.

Then click "Add Web Reference.." on the bottom left of the next dialog.

Now you can add a regular SOAP web reference like you are looking for.

Moose
  • 5,354
  • 3
  • 33
  • 46
  • 1
    Will that require .NET 2.0 too on the computer? Or .NET 4.0 will be able to handle the .NET 2.0 based "Web Reference" technology? I want to know because I am deploying a SOAP webservice as "Web Reference" in a .NET 4.0 application. – Computer User May 06 '14 at 21:06
4

Adding a service reference allows you to create a WCF client, which can be used to talk to a regular web service provided you use the appropriate binding. Adding a web reference will allow you to create only a web service (i.e., SOAP) reference.

If you are absolutely certain you are not ready for WCF (really don't know why) then you should create a regular web service reference.

Otávio Décio
  • 73,752
  • 17
  • 161
  • 228
  • 3
    Because WCF is NOT easy for newbies. And moreover my boss won't let me move to it is the real reason. It's code & run here. When you have that situation, nothing I can do about it bud. – PositiveGuy Jan 28 '10 at 21:43
  • 7
    @coffeeaddict I think you and your boss are mis-informed. Both types of references will create a class which provides methods to call the service operations. How is it relevant that the class created by a "service" reference happens to inherit from a base class which happens to be in a library that Microsoft considers to be part of some technology it calls WCF? – Daniel Pratt Jan 28 '10 at 21:50
  • 2
    Will that require .NET 2.0 too on the computer? Or .NET 4.0 will be able to handle the .NET 2.0 based "Web Reference" technology? I want to know because I am deploying a SOAP webservice as "Web Reference" in a .NET 4.0 application. – Computer User May 06 '14 at 21:06
4

In the end, both do the same thing. There are some differences in code: Web Services doesn't add a Root namespace of project, but Service Reference adds service classes to the namespace of the project. The ServiceSoapClient class gets a different naming, which is not important. In working with TFS I'd rather use Service Reference because it works better with source control. Both work with SOAP protocols.

I find it better to use the Service Reference because it is new and will thus be better maintained.

catfood
  • 4,267
  • 5
  • 29
  • 55