8

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?

Community
  • 1
  • 1
Dave Ziegler
  • 1,737
  • 3
  • 19
  • 36
  • It almost sounds like you are trying to add a reference / consume it incorrectly vs the way that vs 2008 use to do it.. it could also be an aliasing issue as well when trying to consume the webservice url I had some issues similiar when I first started consuming webservices that we created here at our company when using vs2010 but when setting up the same reference in 2008 had zero issues.. – MethodMan Jan 09 '12 at 17:07
  • I've seen this before with a third party ASMX service and I was using 2008. I'm seeing it now with a third party WCF service and I'm in 2010. My steps are detailed above, is there a more correct process I'm not aware of? :-) – Dave Ziegler Jan 09 '12 at 17:11
  • I can't answer the one about entering your credentials because the way we have things setup over here.. it authenticates against our network log in so it's more of a trusted connection.. I wonder if anyone else has seen this issue as well – MethodMan Jan 09 '12 at 17:13
  • Ultimately, it works. I can consume the service after going through the prompt 3x, but the initial discovery process seems a little off for sure. Another weird thing: if I go through this process once and get to the WSDL, then close out of VS and don't save the service ref I added, I can reopen VS and when I go to add the service ref (now ServiceReference2) it lets me right in with no propmt. – Dave Ziegler Jan 09 '12 at 17:18
  • this sounds rather odd unless the indivdual whom created the webservice has some sort silly multiple validation method going on.. I also wonder if it has to deal with fully qualifying the login/validation initially.. fullDomain UserName\Password – MethodMan Jan 09 '12 at 17:21
  • It wouldn't work at all unless I put in the domain (no domain = continuous prompt). After domain\username then I get to the 3x prompt point. No multiple validation going on. Also, if I key the URL to the WSDL in a browser, I am prompted once and then I'm in. This seems to only happen in VS. – Dave Ziegler Jan 09 '12 at 17:25
  • sounds like some security / firewall issues I could be mistaken.. – MethodMan Jan 09 '12 at 17:28
  • I'll keep digging, thanks for the input. – Dave Ziegler Jan 09 '12 at 17:32
  • not a problem.. one more question .. not sure if you mentioned it.. but is this a 3rd party web service or one that you or someone where you are created..? – MethodMan Jan 09 '12 at 17:36
  • One of the problem services was written in house, but this has happened to me with other third party services as well. Maybe you're onto something with the firewall comment... – Dave Ziegler Jan 09 '12 at 17:44
  • it's worth checking out.. or they may have some sort of blocker out there ... in regards to running certain urls – MethodMan Jan 09 '12 at 18:03
  • I'm convinced this is a VS "feature" and here is why: If I go through the steps to add a service reference, enter my creds, and click OK, I get re-prompted immediately. At this point, if I cancel, I'm done. But... if I enter my creds, click OK, get re-prompted, sit there for a minute or two at the prompt, and THEN click cancel, my service ref is there. I think VS gets in a hurry to prompt you for creds over and over before it completes the WSDL download/proxy class generation process. – Dave Ziegler Jan 09 '12 at 21:10

5 Answers5

9

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.

Dave Ziegler
  • 1,737
  • 3
  • 19
  • 36
4

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.

  • 1
    I did enter domain. I didn't say 3 times, I said 3+ times, actually it would continue as many times as I would click ok. – Dave Ziegler Jan 10 '14 at 04:38
0

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.

zippyCow
  • 11
  • 1
  • Yeah, the weird thing to me was if I just waited a few seconds and clicked Cancel, then everything was fine and no more prompts. Thanks for the info. – Dave Ziegler Feb 19 '13 at 20:15
  • By setting "URL Behavior to "Static" I'm able to "Update Web Reference" without throwing the "The custom tool 'MSDiscoCodeGenerator' failed. Value does not fall within the expected range." error. Still had to cancel the logon prompt. Same URL "dynamic" works fine from a 2nd workstation... – StevoKeano Nov 23 '14 at 09:54
0

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.

Community
  • 1
  • 1
Peter Monks
  • 4,219
  • 2
  • 22
  • 38
0

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.

Alek Wnuk
  • 31
  • 2