C# 带身份验证的WCF流媒体
我有一个WCF服务,必须使用Windows和证书身份验证进行保护。 我知道wsHttpBinding不支持流式传输,但它可以通过使用带有customBinding的传输安全性来实现,但我无法做到C# 带身份验证的WCF流媒体,c#,wcf,authentication,streaming,C#,Wcf,Authentication,Streaming,我有一个WCF服务,必须使用Windows和证书身份验证进行保护。 我知道wsHttpBinding不支持流式传输,但它可以通过使用带有customBinding的传输安全性来实现,但我无法做到 <customBinding> <binding name="AuthBinding"> <mtomMessageEncoding maxBufferSize="65535" /> <windowsStreamSecurity p
<customBinding>
<binding name="AuthBinding">
<mtomMessageEncoding maxBufferSize="65535" />
<windowsStreamSecurity protectionLevel="Sign"/>
<httpTransport transferMode="Streamed" maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
我从一个例外到另一个例外:
绑定“System.ServiceModel.Channels.CustomBinding”的安全功能与生成的运行时对象的安全功能不匹配。这很可能意味着绑定包含StreamSecurityBindingElement,但缺少支持流安全性的TransportBindingElement
或
请求消息必须受到保护。这是合同操作('IEntity','WebService.Entity')所必需的。必须由绑定('CustomBinding','WebService.Entity')提供保护
这不是一步到位,而是两步到位
更新 您必须使用具有混合(带有消息凭据的传输)安全模式的自定义绑定 三个绑定元素与消息级安全性相关,它们都派生自
SecurityBindingElement
类
这三个是TransportSecurityBindingElement
、SymmetricSecurityBindingElement和AsymmetricSecurityBindingElement
。TransportSecurityBindingElement
用于提供混合模式安全性。其他两个元素在消息层提供安全性时使用。
当提供传输级安全性时,将使用其他类:
HttpsTransportBindingElement
SslStreamSecurityBindingElement
WindowsStreamSecurityBindingElement
您可以获得以下方面的帮助:
及
这对我来说很有用:
<basicHttpBinding>
<binding name="basic" transferMode="Streamed" messageEncoding="Mtom">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
您面临的实际问题是什么?wsHttpBinding不允许使用流媒体,我必须使用customBinding,但如果您是第一次使用它,这是一个棘手的、棘手的问题&需要花费很长时间。