合同操作'DownloadStream'需要Windows标识才能进行自动模拟
我最近更改了我的绑定配置以允许在我的WCF服务中进行模拟。通过实现这一点,我被要求使用缓冲的TransferMode.Buffered而不是流式传输。虽然这似乎解决了我的问题一段时间,但我注意到大文件(> 200MB)在尝试分配MemoryStream以传递消息时会抛出异常。我的同事和谷歌让我相信Chunking是答案,我已经尝试实现这个样本的一个版本:
MSDN Chunking文章
我修改了TCPChunkingBinding类以从BasicHttpBinding而不是Binding派生,并添加了我们在尝试分块之前使用的必需BasicHttpSecurity属性。
以前使用BasicHttpBinding的所有端点现在都使用TCPChunkingBinding。以下是我对TCPChunkingBinding类所做的修改:
TcpChunkingBinding : BasicHttpBinding, IBindingRuntimePreferences
...
void Initialize()
{
be = new ChunkingBindingElement();
tcpbe = new TcpTransportBindingElement();
tcpbe.TransferMode = TransferMode.Buffered; //no transport streaming
tcpbe.MaxReceivedMessageSize = ChunkingUtils.ChunkSize + 100 * 1024; //add 100KB for headers
this.MessageEncoding = WSMessageEncoding.Mtom;
this.SendTimeout = new TimeSpan(0, 5, 0);
this.ReceiveTimeout = this.SendTimeout;
this.TransferMode = TransferMode.Buffered;
BasicHttpSecurity security = new BasicHttpSecurity();
security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
security.Transport.Realm = string.Empty;
security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
this.Security = security;
我得到的错误是
The contract operation 'DownloadStream' requires Windows identity for automatic impersonation. A Windows identity that represents the caller is not provided by binding ('TcpChunkingBinding','http://tempuri.org/') for contract ('ITestService','http://tempuri.org/'.
当我在示例中的Service类的Host.cs中调用host.open()时。
基本上我的问题是有人可以帮我弄清楚如何让这个样本与模拟和分块一起工作吗?
在任何人回答之前,在尝试分块之前,我最大化了每个缓冲区设置,因为模仿的必要性,我不能使用Streaming transfermode。提前致谢。
没有找到相关结果
已邀请:
0 个回复