-1

我知道这个错误很常见,但是我尝试将解决方案应用于这个问题,但无法解决。

那是我的代码:

        var endpoint = new EndpointAddress(new Uri("http://www3prz.bancobonsucesso.com.br/Servicos/app.svc"), EndpointIdentity.CreateDnsIdentity("bancobonsucesso.com.br"));
        var binding = new WSHttpBinding();

        binding.UseDefaultWebProxy = true;
        binding.Security.Mode = SecurityMode.Message;
        binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
        binding.Security.Message.EstablishSecurityContext = true;
        binding.Security.Message.NegotiateServiceCredential = true;

        var customBinding = new CustomBinding(binding);

        SymmetricSecurityBindingElement security = customBinding.Elements.Find<SymmetricSecurityBindingElement>();
        security.LocalClientSettings.MaxClockSkew = TimeSpan.MaxValue;
        security.LocalClientSettings.DetectReplays = false;

        SecureConversationSecurityTokenParameters secureTokenParams = (SecureConversationSecurityTokenParameters)security.ProtectionTokenParameters;
        SecurityBindingElement bootstrap = secureTokenParams.BootstrapSecurityBindingElement;
        bootstrap.LocalClientSettings.MaxClockSkew = TimeSpan.MaxValue;
        bootstrap.LocalClientSettings.DetectReplays = false;

        ws = new ServicoClient(customBinding, endpoint);
        ws.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
        ws.ClientCredentials.UserName.UserName = "test";
        ws.ClientCredentials.UserName.Password = "test";

        var return = ws.EmitirBoleto("test");
4

2 回答 2

1

在 WCF 绑定中使用 useDefaultWebProxy:

<bindings>
<basicHttpBinding>
<binding name="bindingName"  useDefaultWebProxy="true">

WebProxy wproxy = new WebProxy("new proxy",true);
wproxy.Credentials = new NetworkCredential("user", "pass");
WebRequest.DefaultWebProxy = wproxy;
于 2012-10-03T19:31:28.797 回答
0

此错误可能会导致代理设置出现问题。请使用您的网络浏览器检查代理设置。刚刚更改了连接设置选项->设置->连接设置为自动检测代理设置

祝你好运 ...

于 2014-07-14T05:44:30.060 回答