简体   繁体   English

代理设置设置为“使用自动配置脚本”的 WCF 客户端

[英]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. Internet Explorer 直到知道唯一通过代理服务器连接到 Internet 的应用程序。

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."我不断收到“(407)需要代理身份验证”。

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.简短更新:应用程序应使用默认用户凭据运行,并通过 NTLM 使用这些凭据向代理进行身份验证。 But even when I set the client to do that it doesn't seem to help.但即使我让客户这样做,它似乎也无济于事。

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):保留<binding useDefaultWebProxy="true" />设置,并确保在您的 app.config 文件useDefaultCredentials设置为 true(此设置默认为false ):

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

For more information, see my blog post " Using HTTP Proxy Servers ".有关详细信息,请参阅我的博客文章“使用 HTTP 代理服务器”。

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. Windows 中的 Everyting 似乎使用了 IE 可配置的 Internet 设置,其中包括默认代理。 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. Internet Explorer 在运行时巧妙地为您解决了这个问题,但是如果您尝试使用 Firefox 检索服务 wsdl 左右,我猜您最终会收到用户登录提示。

In any case, try to false the default proxy.在任何情况下,请尝试将默认代理设为 false。

Remember that kerberos authentication does not work very well across different firewalls.请记住,kerberos 身份验证在不同的防火墙中不能很好地工作。 Many organizations have setup up their proxy to use AD for authentication and will only allow the proxy to access internet sites.许多组织已设置其代理以使用 AD 进行身份验证,并且只允许代理访问 Internet 站点。 This setup does not work well for web services and I suspect this is your problem.此设置不适用于 web 服务,我怀疑这是您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM