【问题标题】:WCF: Invalid Security HeaderWCF:无效的安全标头
【发布时间】: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


    【解决方案1】:

    Fiddler 在客户端运行:

    1. 您是否先于客户启动 Fiddler?
    2. 您是否configure your application 代理其流量?
    3. 您确定您的 WCF 使用 HTTP 作为传输方式吗?

    【讨论】:

      猜你喜欢
      • 2015-11-05
      • 2014-02-11
      • 2016-03-24
      • 2016-04-19
      • 2014-09-23
      • 2014-07-30
      • 2016-07-15
      • 2014-04-05
      • 2014-06-23
      相关资源
      最近更新 更多