【发布时间】:2016-05-26 16:14:51
【问题描述】:
我们定制了 IdentityServer 2 以在 Azure AD 中提供身份联合功能(用于 Office 365 等)。这具有用于被动请求者流的 WS-Federation 端点和用于主动客户端的 WS-Trust。 WS-Trust 的 MEX 端点应返回 WS-Trust SOAP 的 WSDL,以响应 POST(如 Lync 使用)和 GET(如 Windows 10 登录使用)。不幸的是,它返回 HTTP 400:ws-trust system.servicemodel.protocolexception “从网络接收的 XML 存在问题”。
var host = new WSTrustServiceHost(config, baseAddresses);
// add behavior for load balancing support
host.Description.Behaviors.Add(new UseRequestHeadersForMetadataAddressBehavior());
// modify address filter mode for load balancing
var serviceBehavior = host.Description.Behaviors.Find<ServiceBehaviorAttribute>();
serviceBehavior.AddressFilterMode = AddressFilterMode.Any;
serviceBehavior.IncludeExceptionDetailInFaults = true;
System.ServiceModel.Security.WSTrustServiceHost 的一个实例正在启动以处理对 WS-Trust 的调用,并处理其元数据。检查 WSTrustServiceHost ctor 中默认添加的 ServiceMetadataBehavior,我们可以看到它确实启用了通过 HTTP 和 HTTPS 进行 GET 的元数据。 http://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Security/WSTrustServiceHost.cs,8c80389f2532b060,references
所以我有点困惑为什么https://myhost.com/issue/wstrust/mex 在使用 POST 时返回元数据,但在发送 GET 时返回 400。在 System.ServiceModel 的 EnqueueMessageAsyncResult.CompleteParseAndEnqueue() 中引发了异常 http://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Channels/HttpPipeline.cs,b347567a68ab778c,references
非常感谢任何帮助!
【问题讨论】:
标签: wcf-binding identityserver2