2012-01-24 3 views
0

서버 코드wcf 서비스에서 대량의 데이터를 스트리밍해야합니다.

public class SIIUnzipDecodeService : ISIIUnzipDecodeService 
{ 
    //Upload the large data file 

    public void UploadFile(RemoteFileInfo request) 
    { 
     FileStream targetStream = null; 
     Stream sourceStream = request.FileByteStream; 

     string uploadFolder = @"C:\upload\"; 
     string filePath = @"C:\upload\1GB.zip"; 
     //Path.Combine(uploadFolder, request.FileName); 

     using (targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None)) 
     { 
      //read from the input stream in 6K chunks 
      //and save to output stream 
      const int bufferLen = 65000; 
      byte[] buffer = new byte[bufferLen]; 
      int count = 0; 

      while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0) 
      { 
       targetStream.Write(buffer, 0, count); 
      } 

      targetStream.Close(); 
      sourceStream.Close(); 
     } 

    } 

인터페이스 메모리 예외 system.outof 오류가 발생.

[ServiceContract] 
public interface ISIIUnzipDecodeService 
{ 
    [OperationContract] 
    void UnzipAndDecode(MemoryStream fileContent); 

    [OperationContract] 
    RemoteFileInfo DownloadFile(DownloadRequest request); 

    [OperationContract] 
    void UploadFile(RemoteFileInfo request); 
} 

[MessageContract] 
public class DownloadRequest 
{ 
    [MessageBodyMember] 
    public string FileName; 
} 

[MessageContract] 
public class RemoteFileInfo : IDisposable 
{ 
    [MessageHeader(MustUnderstand = true)] 
    public string FileName; 

    [MessageHeader(MustUnderstand = true)] 
    public long Length; 

    [MessageBodyMember(Order = 1)] 
    public System.IO.Stream FileByteStream; 

    public void Dispose() 
    { 
     if (FileByteStream != null) 
     { 
      FileByteStream.Close(); 
      FileByteStream = null; 
     } 
    } 
} 
+0

은 Web.config의 – user359562

+0

어떤 생각을 추가를? 제발 도와주세요 – user359562

+0

서버 설정을 전혀 볼 수 없습니다 ... –

답변

1

Tracing 서비스를 활성화 할 수 있습니까? 또한 서비스 구성을 게시하십시오. 당신이 당신의 서비스 구성에서 아래의 것들을 설정했는지 확인하십시오

<dataContractSerializer maxItemsInObjectGraph="2147483647"/> 

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 

<basicHttpBinding> 
     <binding transferMode="Buffered"/> 
</basicHttpBinding> 
+0

다음은 web.config 바인딩 정보입니다. 나는 아직도 나에게 운이 없다고 제안했던 것을하려고 노력했다. "536870912 바이트의 관리 메모리 버퍼를 할당하지 못했습니다. 사용 가능한 메모리의 양이 적을 수 있습니다." – user359562

0
<basicHttpBinding> 
     <binding closeTimeout="00:30:00" 
      openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
      messageEncoding="Text" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"    maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
     <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
     </binding> 
    </basicHttpBinding> 
+0

web.config의 servicebehavior 요소에 datacontractserializer 요소를 추가하고 오류 메시지에서 나타나는 메시지와 유사하다고 가정합니다 매우 거대하면 다시 보냈습니다. 메시지를 압축하거나 초기에 작은 메시지를 보내고 성공했는지 확인하십시오. – Rajesh

+0

SO에서이 질문을 참조하십시오 ... http://stackoverflow.com/questions/3016446/transferring-large-payloads-of-data-serialized -objects-using-wshttp-in-wcf-wit – Rajesh

관련 문제