简体   繁体   中英

Unable to add a Service Reference using a WSDL in Visual Studio

I have URL to web service WSDL:

http://www.webservicex.net/WeatherForecast.asmx?WSDL

I am trying to consume this service in a WPF application (.Net 4.5) in Visual Studio 2012.

I right click on the project -> Add Service Reference and when I try to add the above service reference, I get the following error:

The HTML document does not contain Web service discovery information. Metadata contains a reference that cannot be resolved: ' http://www.webservicex.net/WeatherForecast.asmx?WSDL '. Metadata contains a reference that cannot be resolved: ' http://www.webservicex.net/WeatherForecast.asmx?WSDL '. If the service is defined in the current solution, try building the solution and adding the service reference again.

On "Add Service Reference" window, I now click on "Advanced" button -> "Add Web Reference" button on the bottom -> copy the URL into URL textbox and click "->" button. I see the WSDL in the viewer.

Now I click on "Cancel" and again "Cancel" on "Service Reference Settings" window.

On "Add Service Reference" window, I click "Go" now and I see the Services available to add to the project.

Is this a Visual Studio issue? Why do I have to do that. Why does it not work the first time? Am I missing something on my machine?

I've tried to 'Add Service Reference' for the URL you provided in Microsoft Visual Studio 2010 ( Version 10.0.40219.1 SP1Rel ), Microsoft Visual Studio Ultimate 2012 ( Version 11.0.61030.00 Update 4 ) and in Microsoft Visual Studio Ultimate 2013 ( Version 12.0.30501.00 Update 2 ) and it's working perfect in all of them.

So I can suppose 3 options.

  1. It was the bug in Visual Studio 2012 but it fixed in one of the latest updates.
  2. Something is changed in the WSDL of the service you tried to consume and now this WSDL doesn't trigger the bug you're encountered.
  3. The issue always was related to your installation of VS 2012 only by some reason (faulty VS add-on installed etc).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM