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?

2
  • 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. Commented Mar 6, 2015 at 21:32
  • Your first link goes to an .asmx. Your second one goes to the wsdl of the .asmx. Is it that simple? Commented Mar 6, 2015 at 21:38

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

5 Comments

You're going straight to web references without knowing what the problem is
I agree with @JohnSaunders. You should not work around issues by taking a step back in time.
Thanks. web reference is older than web service, but it works anyway.. I'll have to stick with this since the service provider is not responsible cc/ @JohnSaunders
You should find out why service reference isn't working for you, rather than punting and using a legacy technology which is far less capable.
@JohnSaunders - Any suggestion for this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.