Click here to Skip to main content
15,898,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on wcf application in which I want upload and download large files in local network. but I got failed exception as "400 bad request".

this is server side config file as below

C#
<configuration>
	<system.servicemodel>
    
    
		<services>
   <service behaviorconfiguration="TransferServiceBehavior" name="WcfTransferTest.transfer">
    <endpoint address="transfer" binding="basicHttpBinding" bindingconfiguration="TransferService">
     contract="WcfTransferTest.Itransfer" />
    <host>
     <baseAddresses>
      <add baseaddress="http://localhost:8001/" />
     </baseAddresses>
    </host>
   </endpoint></service>
  </services>
    
		<bindings>
   <basichttpbinding>
    <binding name="TransferService" maxbuffersize="2147483647" maxreceivedmessagesize="2147483647">
     messageEncoding="Text" transferMode="Streamed">
     <readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647">
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </readerquotas></binding>
   </basichttpbinding>
  </bindings>
    
		<behaviors>
      <servicebehaviors>
        <behavior name="TransferServiceBehavior">
          <servicemetadata httpgetenabled="true" />
          <datacontractserializer maxitemsinobjectgraph="2147483647" />
          <servicedebug includeexceptiondetailinfaults="true" />
          <servicethrottling>
               maxConcurrentCalls="500"
               maxConcurrentSessions="500"
               maxConcurrentInstances="500"/>
        </servicethrottling></behavior>
      </servicebehaviors>
		</behaviors>
    
		<servicehostingenvironment multiplesitebindingsenabled="false" />
	</system.servicemodel>
	<system.webserver>
		<modules runallmanagedmodulesforallrequests="true" />
	</system.webserver>
	<system.web>
		<compilation debug="true" /></system.web></configuration>


this is client side config file as below
C#
<configuration>
    <system.servicemodel>

      <behaviors />

      <bindings>
        <basichttpbinding>
          <binding name="BasicHttpBinding_Itransfer" closetimeout="04:01:00">
            openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
            useDefaultWebProxy="true">
            <readerquotas maxdepth="128" maxstringcontentlength="2147483647">
              maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            <security mode="None">
              <transport clientcredentialtype="None" proxycredentialtype="None">
                realm="" />
              <message clientcredentialtype="UserName" algorithmsuite="Default" />
            </transport></security>
          </readerquotas></binding>
        </basichttpbinding>
      </bindings>

      <client>
        <endpoint address="http://localhost:3778/transfer.svc/transfer">
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Itransfer"
          contract="FileService.Itransfer" name="BasicHttpBinding_Itransfer" />
      </endpoint></client>
      
    </system.servicemodel>
</configuration>


when I set client side transferMode to buffered it can upload small file like KB, and show error when file more than 1MB . but it does not make sense , because I set transferMode to Streamed on server side, and client should be same.
when client and service both set to streamed , I receive "bad request 400" . it took my two day and I tried many suggestions , people said it works for them , but mine is not.

in my code chunk Size is 65000.

please tell me concrete answer , like which parameter in config file is got wrong.
could anyone tell me how to fix this error? I tried many solution, maybe I am missing something here.
how can fix that in order to upload large file through basicHttpBinding with Streamed mode?

thanks in advance!
Posted
Updated 15-Sep-11 0:53am
v3

Here's some shocking info - you may actually have to write some code.

Look at the answer by zuninet here:

http://social.msdn.microsoft.com/forums/en-US/wcf/thread/f00037f1-02e1-4e1c-b6ed-03fe134f3460/[^]
 
Share this answer
 
Comments
BobJanova 14-Sep-11 7:50am    
Good link. Streaming is the answer here.
Alimjan Yasin 15-Sep-11 6:54am    
it did not work for me, but thanks
I don't think BasicHTTPBinding is enough for transferring large data. You need to go for something like WsHttpMtomBinding as discussed here[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900