我知道这个错误非常常见,但我尝试将解决方案应用于此问题但无法解决。
这是我的代码:
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");
答案 0 :(得分: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;
答案 1 :(得分:0)
代理设置可能会出现此错误问题。 请使用Web浏览器检查代理设置。刚刚更改了连接设置选项 - &gt;设置 - &gt;连接设置为自动检测代理设置
祝你好运......