2012-11-02 1 views
0

WCF를 통해 대용량 파일을 업로드하려면이 문서 http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP을 읽었습니다.WCF 스트리밍 대용량 파일

동일한 구성을 만들었지 만 파일을 업로드 할 때도 012kb을 추가하더라도 48kb를 업로드했습니다. 48KB가 넘는 파일을 업로드하려고하면 오류가 발생합니다.

The remote server returned an error: (413) Request Entity Too Large.

내가 잘못되었거나 누락 되었습니까?

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <httpRuntime executionTimeout="4800" maxRequestLength="2097150"/> 
    </system.web> 
    <system.serviceModel> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    <!--BINDING--> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="TransferService" 
       closeTimeout="00:10:00" 
       maxBufferPoolSize="2147483647" 
       maxBufferSize="2147483647" 
       maxReceivedMessageSize ="2147483647" 
       openTimeout="00:10:00" 
       receiveTimeout="00:10:00" 
       sendTimeout="00:10:00" 
       messageEncoding="Text" 
       transferMode="Streamed" 
       > 
      <readerQuotas 
      maxDepth="2147483647" 
      maxStringContentLength="2147483647" 
      maxBytesPerRead="2147483647" 
      maxNameTableCharCount="2147483647" 
      maxArrayLength="2147483647"/> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

    <!--SERVICE--> 
    <services> 
     <service name="TransferService.TransferService" 
       behaviorConfiguration="TransferServiceBehavior" > 
     <endpoint 
      address="" 
      binding="basicHttpBinding" 
      bindingConfiguration="TransferService" 
      contract="TransferService.ITransferService" > 
     </endpoint> 
     </service> 
    </services> 

    <!--BEHAVIOR--> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="TransferServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500" /> 
     </behavior> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
<system.webServer> 
    <security> 
    <requestFiltering> 
     <requestLimits maxAllowedContentLength="500000000"></requestLimits> 
    </requestFiltering> 
    </security> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

웹 클라이언트 설정 :

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_ITransferService" /> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint name="BasicHttpBinding_ITransferService" 
      address="http://localhost/transfer/TransferService.svc" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_ITransferService" 
      contract="TransferService.ITransferService" /> 
    </client> 
    </system.serviceModel> 

어떤 솔루션을 제안하십시오 아래 내 설정

서버 설정입니다. 당신의 제안으로


사전

에서

덕분에 지금은 설정을 변경했지만 여전히 400 또는 413 아래는 내 테스트 프로젝트 같은 오류가 발생합니다. 왜 그런지 모르겠어? (환경 : 윈도우 7 프로 64 비트, IIS7, WCF 4.0)

나는 연구와 이주 보낸거야하지만이 같은 오류의

https://skydrive.live.com/redir?resid=BFE92959302FBAA0!105&authkey=!ANO_URChpql9gKE

.

도와주세요. 미리 감사드립니다.

+0

NetTCp처럼 다른 프로토콜을 사용해야합니다 ... 파일 보내기에 basicHTTP를 사용하지 마십시오. –

답변

1

클라이언트 구성 도 동일한 바인딩 구성 (전송 크기가 더 높음)을 정의해야하며 해당 끝점 구성에서 바인딩 구성을 지정해야합니다.

그래서 당신의 클라이언트 측 설정을 변경

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="TransferService" 
       closeTimeout="00:10:00" 
       maxBufferPoolSize="2147483647" 
       maxBufferSize="2147483647" 
       maxReceivedMessageSize ="2147483647" 
       openTimeout="00:10:00" 
       receiveTimeout="00:10:00" 
       sendTimeout="00:10:00" 
       messageEncoding="Text" 
       transferMode="Streamed" 
       > 
      <readerQuotas 
      maxDepth="2147483647" 
      maxStringContentLength="2147483647" 
      maxBytesPerRead="2147483647" 
      maxNameTableCharCount="2147483647" 
      maxArrayLength="2147483647"/> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

    <client> 
     <endpoint name="BasicHttpBinding_ITransferService" 
      address="http://localhost/transfer/TransferService.svc" 
      binding="basicHttpBinding" 
      bindingConfiguration="TransferService" 
      contract="TransferService.ITransferService" /> 
    </client> 
    </system.serviceModel> 

한 다음 이 클라이언트와 서버에 동일한 설정을해야하고, 다음 이러한 설정이 유용 될 것을!

+0

동일한 구성을 복사 한 다음 웹 클라이언트 구성에 추가했습니다. 하지만 난 오류가 발생했습니다 원격 서버가 오류를 반환했습니다 : (400) 잘못된 요청. – nvtthang

0

동일한 문제가 있습니다. 그리고 내가 25메가바이트 파일을 업로드 할 수 있어요 다음 설정 파일에이 코드를 사용하고 이

<system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="webserviceMOSSuiteSoap" 
       closeTimeout="00:01:00" 
       maxBufferPoolSize="20000000" 
       maxBufferSize="20000000" 
       maxReceivedMessageSize="20000000" 
       openTimeout="00:01:00" 
       receiveTimeout="00:10:00" 
       sendTimeout="00:01:00" 
       messageEncoding="Text" 
       transferMode="Buffered" 
       allowCookies="false" 
       bypassProxyOnLocal="false" 
       hostNameComparisonMode="StrongWildcard"       
       textEncoding="utf-8"      
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" 
          maxStringContentLength="20000000" 
          maxArrayLength="20000000" 
          maxBytesPerRead="20000000" 
          maxNameTableCharCount="20000000"/> 
       <security mode="None"> 
       <transport clientCredentialType="None" 
        proxyCredentialType="None" 
        realm=""/> 
      <message clientCredentialType="UserName" 
       algorithmSuite="Default"/> 
          </security> 
        </binding> 
      </basicHttpBinding> 
     </bindings> 
<client>  
     <endpoint address="http://localhost/WebServiceConnect/webservice.asmx" 
        binding="basicHttpBinding" 
        bindingConfiguration="webserviceMOSSuiteSoap" 
        contract="ServiceReference1.webserviceMOSSuiteSoap" 
        name="webserviceMOSSuiteSoap"/> 
    </client> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
           multipleSiteBindingsEnabled="true"/> 
</system.serviceModel> 
1
내가 확인

프로젝트를하려고이 당신의 webconfig를 교체하고 서비스 참조 다시 시도 업데이트

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <httpRuntime executionTimeout="4800" maxRequestLength="2097150"/> 
    </system.web> 
    <system.serviceModel> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    <!--BINDDING--> 
    <bindings> 
     <basicHttpBinding> 
     </basicHttpBinding> 
     <customBinding> 
     <binding name="LargeSilverlight" closeTimeout="00:21:00" openTimeout="00:20:00" 
      receiveTimeout="00:20:00" sendTimeout="00:50:00"> 
      <textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
       maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      </textMessageEncoding> 
      <httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
      maxBufferSize="2147483647" /> 
     </binding> 
     </customBinding> 
    </bindings> 
    <client> 
    </client> 
    <!--SERVICE--> 
    <services> 
     <service name="TransferService.TransferService" behaviorConfiguration="SilverlightWCFLargeDataApplication" > 
     <endpoint address="" binding="customBinding" bindingConfiguration="LargeSilverlight" behaviorConfiguration="SilverlightWCFLargeDataApplication" contract="TransferService.ITransferService" > 
     </endpoint> 

     </service> 
    </services> 

    <!--BEHAVIOR--> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="SilverlightWCFLargeDataApplication"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 

     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="SilverlightWCFLargeDataApplication"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 


    </system.serviceModel> 
    <system.webServer> 

    <security> 
     <requestFiltering> 
     <requestLimits maxAllowedContentLength="500000000"></requestLimits> 
     </requestFiltering> 
    </security> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 
+0

좋은 작품 Sanjeetharan, +1 – Vinnie