Search code examples
c#wcfwcf-binding

WCF client with proxy settings set to "Use automatic configuration script"


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.


Solution

  • 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".