WCF:无效的安全标头

时间:2014-05-14 13:41:56

标签: wcf .net-4.0 wcf-binding wcf-security fiddler

通常当我使用Web服务时,我会添加一个服务引用,放入WSDL的URL,然后通过API来完成。

这一次,我收到一条错误消息:"无效的安全标题"。

这是我的约束力:

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跟踪似乎只是表面沟通"里程碑" (如果那个词含有一些胜利的味道,我就会离开!)。

1 个答案:

答案 0 :(得分:0)

Fiddler在客户端上运行:

  1. 你在客户面前开始Fiddler吗?
  2. 你有configure your application代理其流量吗?
  3. 您确定您的WCF使用HTTP作为传输吗?