开发者

The contract operation 'DownloadStream' requires Windows identity for automatic impersonation

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:

MSDN Chunking Article

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 t开发者_开发知识库o 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜