[c#] Web Reference vs. Service Reference

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?

This question is related to c# .net-3.5 paypal

The answer is


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.


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.


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.


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.


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to .net-3.5

Get first element from a dictionary redistributable offline .NET Framework 3.5 installer for Windows 8 How to read an entire file to a string using C#? HTTP Error 500.22 - Internal Server Error (An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.) Change the Textbox height? How to get current date in 'YYYY-MM-DD' format in ASP.NET? C# Numeric Only TextBox Control Will the IE9 WebBrowser Control Support all of IE9's features, including SVG? Use LINQ to get items in one List<>, that are not in another List<> Get Absolute URL from Relative path (refactored method)

Examples related to paypal

Django - Reverse for '' not found. '' is not a valid view function or pattern name Test credit card numbers for use with PayPal sandbox Setting PayPal return URL and making it auto return? How to solve javax.net.ssl.SSLHandshakeException Error? InvalidKeyException : Illegal Key Size - Java code throwing exception for encryption class - how to fix? Building a complete online payment gateway like Paypal Web Reference vs. Service Reference