将WS2007FederationHttpBinding与SOAP 1.1一起使用

时间:2013-09-10 17:17:09

标签: wcf wif

有没有办法使用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,因为它是只读属性?

1 个答案:

答案 0 :(得分:1)

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

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

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