合约操作“DownloadStream”需要 Windows 身份才能自动模拟
我最近更改了绑定配置,以允许在我的 WCF 服务中进行模拟。通过实现这个,我需要使用缓冲的 TransferMode.Buffered 而不是流式传输。虽然这似乎暂时解决了我的问题,但我注意到大文件(> 200MB)在尝试分配 MemoryStream 来传递消息时会抛出异常。我的同事和谷歌让我相信分块就是答案,此后我尝试实现此示例的一个版本:
我修改了 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() 时。
基本上我的问题是有人可以帮助我弄清楚如何让这个样本与模拟和分块一起使用吗?
在任何人回答之前,在尝试分块之路之前,我已经最大化了每个缓冲区设置,并且由于模拟的必要性,我无法使用流传输模式。提前致谢。
I recently changed my binding configurations to allow impersonation in my WCF service. By implementing this, I was required to use a buffered TransferMode.Buffered as opposed to streamed. While this seemed to fix my problems for a while, I noticed that large files (>200MB) would throw an exception when trying to allocate the MemoryStream to pass in the message. My colleagues as well as google led me to believe that Chunking was the answer and I've since tried to implement a version of this sample:
I modified the TCPChunkingBinding class to derive from BasicHttpBinding instead of Binding and added the requisite BasicHttpSecurity attributes that we used before trying chunking.
All the endpoints that previously used BasicHttpBinding now use TCPChunkingBinding. Here are the modifications I made to the TCPChunkingBinding class:
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 error I get is
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/'.
When i call host.open() in Host.cs of the Service class in the sample.
Basically my question is can someone help me figure out how to get this sample working with impersonation and chunking?
Before anyone answers, prior to trying the chunking road I maxed out every buffer setting and I cannot use Streaming transfermode because of the necessity for impersonation. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论