【发布时间】:2014-05-14 13:41:55
【问题描述】:
通常,当我使用 Web 服务时,我会添加一个服务引用,输入 WSDL 的 URL,然后通过 API 找到自己的方式。
这一次我收到一个 FaultException 消息:“无效的安全标头”。
这是我的绑定:
CustomBinding bindingBNP = new CustomBinding();
SecurityBindingElement securityElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
securityElement.DefaultAlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Basic128;
securityElement.KeyEntropyMode = System.ServiceModel.Security.SecurityKeyEntropyMode.CombinedEntropy;
securityElement.IncludeTimestamp = false;
securityElement.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
MtomMessageEncodingBindingElement mtomElement = new MtomMessageEncodingBindingElement(MessageVersion.Soap11WSAddressing10, Encoding.UTF8);
HttpsTransportBindingElement httpsElement = new HttpsTransportBindingElement();
httpsElement.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
httpsElement.BypassProxyOnLocal = false;
httpsElement.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
httpsElement.ManualAddressing = false;
httpsElement.ProxyAuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
httpsElement.TransferMode = TransferMode.Buffered;
httpsElement.UnsafeConnectionNtlmAuthentication = false;
httpsElement.RequireClientCertificate = false;
httpsElement.UseDefaultWebProxy = false;
bindingBNP.Elements.Add(securityElement);
bindingBNP.Elements.Add(mtomElement);
bindingBNP.Elements.Add(httpsElement);
相关问题:出于诊断目的,我如何知道入站/出站通信是什么?
Fiddler 似乎什么都没有(我想它必须在服务器机器上,我可能无法协商)。 WCF 跟踪似乎只是表面通信“里程碑”(如果这个词意味着某种胜利的味道,我就差远了!)。
【问题讨论】:
标签: wcf .net-4.0 wcf-binding wcf-security fiddler