12

I'm currently developing an application that needs to communicate with a webservice on the internet. Internet explorer is until know the only application that is connecting to the internet through a proxy server.

The proxy settings are setup to "Use automatic configuration script".

I have kept the default setting

<binding useDefaultWebProxy="true" />

And additionally set

<security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" proxyCredentialType="Basic"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
</security>

But no luck. I keep getting "(407) Proxy Authentication Required."

I have done some Google-ing, but the solutions do not seem to fit my situation.

Short update: The application should run with the default user credentials, and use those credentials through NTLM to authenticate with the proxy. But even when I set the client to do that it doesn't seem to help.

Saab
  • 981
  • 3
  • 11
  • 34
  • Are you sure you need to send credentials to proxy via Basic authentication? That would require you to set user name and password in client credentials of the proxy. – Ladislav Mrnka Apr 28 '11 at 08:29
  • Good point. Changing it to Windows right now. But I assume it means it automatically will use default credentials. – Saab Apr 28 '11 at 08:49
  • Does this answer help ? http://stackoverflow.com/questions/289601/connecting-to-an-asmx-webservice-with-wcf-through-a-proxy – KeesDijk Apr 28 '11 at 09:25
  • did you try setting proxy.useDefaultCredentials to true programatically? – Aravind May 20 '11 at 10:32

3 Answers3

8

Keep the <binding useDefaultWebProxy="true" /> setting, and make sure useDefaultCredentials is set to true in your app.config file (this setting is false by default):

<system.net>
    <defaultProxy useDefaultCredentials="true"/>
</system.net>

For more information, see my blog post "Using HTTP Proxy Servers".

Bradley Grainger
  • 27,458
  • 4
  • 91
  • 108
1

I can't give you any background on why but setting:

<binding useDefaultWebProxy="false" />

Works for me in my current environment when getting your exact error. Everyting in Windows seems to use the IE-configurable internet settings which include the default proxy. Internet explorer fixes this up for you neatly when running but if you try to retrieve the service wsdl or so using Firefox I´m guessing you would end up having a user login prompt.

In any case, try to false the default proxy.

Almund
  • 5,695
  • 3
  • 31
  • 35
  • When reading the WCF documentation, setting it to false would use the setting on user level. But this I tried it before, and it didn't solve my problem. – Saab May 23 '11 at 14:47
  • Ok, that explains why it works for me however. Too bad it didn't help. – Almund May 25 '11 at 12:40
0

Remember that kerberos authentication does not work very well across different firewalls. Many organizations have setup up their proxy to use AD for authentication and will only allow the proxy to access internet sites. This setup does not work well for web services and I suspect this is your problem.

Frode Stenstrøm
  • 1,048
  • 7
  • 24