2011-06-20 7 views
0

ストリーミング: WCFは、私はこの設定でWCFサービスライブラリを持ってerrror(最大メッセージサイズクォータ)

<basicHttpBinding> 
    <binding name="httpLargeMessageStream" 
     maxReceivedMessageSize="2147483647"  
     messageEncoding="Mtom" transferMode="Streamed" /> 
</basicHttpBinding> 

<netTcpBinding> 
    <binding name="tcpLargeMessageStream" transferMode="Streamed" 
      maxReceivedMessageSize="2147483647" /> 
</netTcpBinding> 

と、クライアント側からの

私は、アップロードファイルの要求を送信する場合、すべてが正常に動作

public void UploadFile(FileUploadMessage request) 
{ 
    try 
    { 
     // Gets absolute local storing path 
     string localPath = Path.Combine(basePath, request.UploadMetadata.StoringPath); 

     // Create folders in they don't exist 
     FileInfo file = new System.IO.FileInfo(localPath); 
     file.Directory.Create(); 

     // Get document path on server 
     string serverFileName = Path.Combine(localPath, request.UploadMetadata.HashFileName); 

     // Create a new temp document 
     using (FileStream outfile = new FileStream(serverFileName, FileMode.Create)) 
     { 
     // Read buffer 
     const int bufferSize = 65536; 

     // Output buffer 
     Byte[] buffer = new Byte[bufferSize]; 
     int bytesRead; 

     // Write bytes from source into local file 
     while ((bytesRead = request.FileByteStream.Read(buffer, 0, bufferSize)) > 0) 
     { 
      outfile.Write(buffer, 0, bytesRead); 
     } 
     } 
    } 
    catch (IOException e) 
    { 
     throw new FaultException<IOException>(e); 
    } 
} 

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

public FileDownloadReturnMessage DownloadFile(FileDownloadMessage request) 
{ 
    try 
    { 
     controlServerAdress = "http://localhost:8080/ControlServer/"; 

     EndpointAddress basicBinding = new EndpointAddress(controlServerAdress + "TokenService/basic"); 
     tokenService = new TokenServiceClient("BasicHttpBinding_ITokenService", basicBinding); 

     // Get file token form control server 
     ComDocFile file = tokenService.ResolveToken(request.DownloadMetadata.Token); 

     // If exist file for token 
     if (file != null) 
     { 
     // Get document path on server 
     string serverFileName = Path.Combine(basePath, file.FilePath, file.FileName); 

     // Set fileName 
     request.DownloadMetadata.FileName = file.FileName; 

     // Return file stream 
     return new FileDownloadReturnMessage(new FileStream(serverFileName, FileMode.Open, FileAccess.Read), new ReturnDownloadMetaData(file.FileName, true)); 
     } 

     return new FileDownloadReturnMessage(null, 
        new ReturnDownloadMetaData(null, false)); 
    } 
    catch (IOException e) 
    { 
     throw new FaultException<IOException>(e); 
    } 
} 

が、ダウンロード要求のために私はすでにエラーを得ました

クライアントを呼び出す方法:

// Read buffer 
const int bufferSize = 65536; 

// Output buffer 
Byte[] buffer = new Byte[bufferSize]; 
int bytesRead; 

// Prepare download stream 
Stream donwloadStream; 

ReturnDownloadMetaData file = fileClient.DownloadFile(downloadMetaData, out donwloadStream); 

// If file server return valid file stream 
if (file.IsValid) 
{ 
    // Create a new temp document 
    using (FileStream outfile = new FileStream("C:\\#ComDocs_FileServer\\" + file.FileName, FileMode.Create)) 
    { 
     // Write bytes from source into local file 
     while ((bytesRead = donwloadStream.Read(buffer, 0, bufferSize)) > 0) 
     { 
      outfile.Write(buffer, 0, bytesRead); 
     } 
    } 
} 

答えて

4

maxReceievedMessageSizeは、データが受信機が受け入れる用意があるということがいかに大きいです。上のコードでは、ダウンロードのためにクライアントが受信者です。あなたが同様にクライアントにmaxReceievedMessageSizeを増やす必要

+0

Blewett thx man!間違った断層。 –

0

使用この

のMaxBufferSize =「2147483647」maxReceivedMessageSize =「2147483647」

(あなたが示されているコードからこれをやっているように見えません)送信側と受信側の両方で

関連する問題