0

有没有办法使用 WS2007FederationHttpBinding 绑定,但生成 SOAP 1.1 请求信封?我需要使用 WS2007FederationHttpBinding 使用从 STS 服务获取的不记名令牌进行身份验证。这是我的绑定:

    private static Binding GetWS2007FederationHttpBinding()
    {
        var binding = new WS2007FederationHttpBinding(
            WSFederationHttpSecurityMode.TransportWithMessageCredential);
        binding.Security.Message.NegotiateServiceCredential = false;
        binding.Security.Message.EstablishSecurityContext = false;
        binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;
        //binding.MessageVersion.Addressing = AddressingVersion.WSAddressingAugust2004;
        //binding.MessageVersion.Envelope = EnvelopeVersion.Soap11;
        // or
        //binding.MessageVersion = MessageVersion.Soap11WSAddressingAugust2004;
        return binding;
    }

但我不能改变binding.MessageVersion,因为它是一个只读属性?

4

1 回答 1

1

你需要一个自定义绑定。一种方法是静态声明等效于 WS2007FederationHttpBinding 的自定义绑定 - 可能需要一段时间来微调它。或者您可以在代码中创建 WS2007FederationHttpBinding(就像您一样),将其克隆到自定义绑定中:

CustomBinding outputBinding = new CustomBinding(federationBinding.CreateBindingElements());

然后找到文本消息编码通道并更改其soap版本。

于 2013-09-10T17:28:57.737 回答