7

I want to add a web service to my ASP.NET MVC 5 project.

I do that by right click on the project in solution explorer > add > service reference.

Then I add a web service url like this and it creates a new file in Service References folder called ServiceReference1

Then I'm able to call web service methods in C# by using ServiceReference1 namespace and VS intellisense works.

The problem is that when I add this web service url, it adds a new namespace (ServiceReference2) to that folder, but I can't call the new namespace and it says ServiceReference2 namespace could not be found.

Is it me doing something wrong or the web service has a problem?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
user4641936
  • 73
  • 1
  • 1
  • 3
  • You're doing it the right way. It could be a problem with the service. Notice that the first one works but the second one does not, so the issue must be with the difference between the services. – John Saunders Mar 06 '15 at 21:32
  • Your first link goes to an .asmx. Your second one goes to the wsdl of the .asmx. Is it that simple? – moarboilerplate Mar 06 '15 at 21:38

1 Answers1

13

After you open your service window, click on the advanced button like below.

In general, I agree it's best not to use the older versions of web-services like I'm showing here, but in real life people have deadlines and such.

Saying that though, there is no huge drawback to using this tech, as long as performance isn't an issue.

enter image description here

Then, click 'add Web Reference' like the picture below.

enter image description here

Then enter URL and click on the little arrow button. Name your reference and click 'Add Reference'. see pic below

enter image description here

sam starobin
  • 258
  • 3
  • 12