Thursday, December 9, 2010

Tip On Preventing Web Discover Service Error

I have been using .asmx web services for about 7 years now, and have not run into too many issues while consuming valid URLs in VS.NET. And although I am not creating new .asmx services today because I prefer (as should you) WCF services, I still have some that have yet to be converted.

One service in particular was giving me issue upon consuming in VS.NET 2010 with the following error message in a dialog box named "Web Discovery Service":

"Unable to download following files from . Do you want to skip these files and continue?"

Well I found very little documentation on this issue (actually only 2 sites on Google), but I did manage to find the solution which on the surface appears quite obvious after explanation.

It started when I moved an upgraded copy of this service (Framework 4.0, IIS 7.5, etc) to a new server. However I had the "myservice" SSL certificate imported and applied to this service in IIS that was named "myservice08" (name was only for testing). I knew ahead of time that I would get certificate mismatch errors ("myservice" <> "myservice08") because the SSL cert didn’t match the sites host name, but I figured for testing I could bypass and be OK. Well this ended up being a showstopper, because not only did I get the warning about the SSL certificate not matching the host name upon consumption, I got the other error reported above as well (which is not nearly as indicative of the SSL mismatch being as issue). In fact I was really thrown off because the .asmx service would still come up in the browser showing the wsdl just fine.

So if you ever are working with legacy .asmx services and are receiving the same error I did upon consuming within VS.NET, make sure that the SSL cert name and the hostname of the service are identical.