Question

I started a new blank console app project in VS (I am using VS2010), and choose Add Service Reference to a web service protected with a username and password.

When I click Go in the dialog box, I'm confronted with a Yes/No prompt to accept a certificate. I choose Yes, then I arrive at a Discovery Credential prompt asking for User Name and Password.

If I key those in correctly several times (3+), I finally gain access to the WSDL. Or, oddly enough if I key them correctly once, then cancel, then go through the process again, my creds are accepted on the first attempt.

I asked The Googles and found a few instances related to SQL reporting web services, and someone posted here about something similar, but no one seems to have a definitive answer.

Can anyone explain this odd behavior? Is the service configured incorrectly or is this some sort of known issue with web services or WCF services?

Was it helpful?

Solution

I'm not sure if this is the answer yet or not, but I'm posting this in case it helps someone else.

From what I have seen, if you get into a continuous username+password prompt problem when adding a web reference or service reference to a secure web service and you are certain you are entering the credentials correctly, make sure you try two things:

1) Use domain\username vs. username only

2) After you enter your credentials at least once correctly and you are prompted a second time, DON'T DO ANYTHING FURTHER for 30-60 seconds (I just made that up, YMMV). If you wait on the prompt and then click Cancel, the service reference may be sitting there waiting for you to add to the project.

From what I am seeing, Visual Studio gets in a hurry and re-prompts you before it has time to download the WSDL and/or generate proxy classes.

OTHER TIPS

I got almost the same issue. Needed to provide credentials more than 3 times and it never stopped. Enabling anonymous is not a real solution. It than won't ask for credentials.

The solution (without anonymous): - enter username with DOMAIN information. At my customers environment there are two domains.

That you get the prompt three times is (I think) because it's doing some discovery stuff on three different url's.

Struggled with this one a lot yesterday & google was not much help other than finding others running into the same confusion.

I could browse the wsdl just fine in IE, so IE was passing credentials just fine. So after like 5 hours of "wtf" decided that the add reference for discovery dialog in VS2010 just was not passing credentials.... evidenced by the error msg indicating the server doesnt permit anonymous authentication.

"well so wouldn't it provide my credentials the same way IE does?"

Um, so maybe not. maybe I was assuming that it would. Maybe VS2010 ONLY wanted anonymous authentication for discovery.

Checking the SSRS services I was trying to "discover", found anonymous was not permitted.

So in my case VS2010 wanted to authenticate anonymously for discovery and didn't seem to want to supply credentials in the same fashion IE did.

So I opened IIS on the hosting server, enabled anonymous authentication for the SSRS services and VS2010 stopped presenting the useless login prompts.

Service reference dropped in & the proxies were generated.

I haven't tried disabling anonymous access, but I have the sense that since I'm going to pass ClientCredentials to the proxy when I use it, that it will be safe to disable anonymous access on the host.

VS2010 just needed to authenticate anonymously from that dialog, I am guessing. It wasn't fall back to provide the credentials as I was assuming it would.

I've had the same issue trying to connect to a secure 3rd party web service despite the fact that I have the credentials and they do work.

One workaround I did find that worked though was from this StackOverflow answer - it seems you might be able to enter the credentials as part of the discovery URL as follows:

http://[username]:[password]@[serviceUrl]/service?wsdl

e.g.

http://bob1:password1@myservice.com/service?wsdl

When I tried this method using the Add Service Reference dialog I no longer got those credential popup windows and the proxy classes were created without issue.

I stumbled across a similar case today. I followed many workarounds but neither of them worked. Then I tried a new approach: instead of typing http://server.domain.name/path/to/wsdl I entered http://server.ip.address/path/to/wsdl and it worked as a charm.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top