Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WCF
HI,
I have created WCF services which allow desktop based application to upload/download large file through wcf service.
The service is working working properly the way it should but the problem is that i can not upload large file from Desktop application. I am storing that uploaded file directly to the database using Byte[]
 
here is my web.config
----------------------------------
<?xml version="1.0"?>
<configuration>
  <connectionStrings>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147483647"/>
  </system.web>
  <system.serviceModel>
 
      <bindings>
 
      <basicHttpBinding>
 
        <binding name="BasicHttpBinding_IFileHandlerDuplex" closeTimeout="01:10:00"
         openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00"
         allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
         messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
         useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" 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>
    </bindings> 
    <behaviors>
      
      <serviceBehaviors>
        <behavior>
      
         <!--To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment--> 
          <serviceMetadata httpGetEnabled="true"/>
             <!--receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information--> 
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
 
</configuration>
 

 

can you tell what should i do to upload/download large to/file from database using WCF service ?
Posted 21-Mar-13 21:21pm
Edited 21-Mar-13 21:23pm
v2
Comments
bluesathish at 22-Mar-13 6:09am
   
do you got any errors while upload large files? if yes, what it is?
Kalpesh_Bhadra at 25-Mar-13 1:16am
   
the error is as follow
 
1>
The remote server returned an unexpected response: (400) Bad Request.
 

2>
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:FileAttachment. The InnerException message was 'There was an error deserializing the object of type CAIS_BusinessObjects.CAIS_FileAttachmentBO. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 27123.'. Please see InnerException for more details.
bluesathish at 25-Mar-13 1:43am
   
what kind of data you're uploading? whether it is a block of records to be inserted into the table or what?
Kalpesh_Bhadra at 25-Mar-13 2:14am
   
i have allowed user to upload any kind of file to the database.
generally it ll be type of images, documents or a zip type of files.
on the desktop application it allowing me to upload small sized images and document
bluesathish at 25-Mar-13 2:47am
   
I thought your parameters in webconfig are fine. Everything has some limits, if you upload beyond the limit of the acceptable size means how the system can able to handle that? so my point is better you try to compress your inputs if it thorws errors.
Kalpesh_Bhadra at 25-Mar-13 3:02am
   
but my client don't want to put restriction over the size of file.
they want to upload doc, pdf or any ms office file of any size.
here web user can upload any amount of file but where as desktop application cant, i have edited "app.config" file which i had posted below,
is there anything to change with that?
bluesathish at 25-Mar-13 3:14am
   
Your appconfig was the problem, i found where you're missing and i posted the solution. check it out.
bluesathish at 25-Mar-13 4:01am
   
have you tried, i'm looking fwd your reply.
Kalpesh_Bhadra at 25-Mar-13 4:21am
   
i extreamy thank for your suggetion but
again it shows bad request 400 exception
bluesathish at 25-Mar-13 5:04am
   
Check this out
http://www.codeproject.com/Articles/169928/WCF-Service-returns-400-Bad-Request
bluesathish at 25-Mar-13 5:14am
   
Check this out too
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/23c28d52-4a42-4785-970e-dd77c5c64f1d
Kalpesh_Bhadra at 25-Mar-13 5:55am
   
@bluesathish: both the article suggesting to increase the all the "max" element of web.config file.
i have set it to 2147483647 nothing working out.
even i cant upload file size up to 1mb
Kalpesh_Bhadra at 25-Mar-13 6:32am
   
i want to re configure my both app.config and web.config file.
none of this is working out
what should i do now?
Kalpesh_Bhadra at 25-Mar-13 6:44am
   
i am uploading file using entity class in WVF services
Kalpesh_Bhadra at 26-Mar-13 4:49am
   
@bluesathish: i am stuck with this problem since 15 days. please help me to get over it. i can download any amount of file but uploading is limited to 16kb
bluesathish at 26-Mar-13 4:57am
   
Sorry i've shares all the possiblities from my knowledge, you can search for the alternatives.
Kalpesh_Bhadra at 28-Mar-13 1:37am
   
thank you bluesathish for your kind help.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

if it is working in a browser, it will work in an app as well. my guess is that you have to specify some parameteres like timeout, etc. to get it to work (in the desktop app!).
  Permalink  
v2
Comments
Kalpesh_Bhadra at 22-Mar-13 8:49am
   
yes it working properly on browser but shows error on desktop application
and the error is as follow
 

i am passing an object of class which contains the following Fields
 
public long FileID;
public long ClientID;
public long AdvisorID;
public string Owner;
public string FileName;
public string FileMIME;
public byte[] FileStream;
//i want to restrict user not to upload file more than size of 100mb
public bool Is_Password;
public string Password;
public string FileType;
public string FileDesc;
public DateTime Created_On;
 

 

--------------
The remote server returned an unexpected response: (400) Bad Request.
 
-----------------
 
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:FileAttachment. The InnerException message was 'There was an error deserializing the object of type CAIS_BusinessObjects.CAIS_FileAttachmentBO. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 27123.'. Please see InnerException for more details.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

here is my app.config file of the application
 
---------------------------------------------------
 
<configuration>
    <system.servicemodel>
        <bindings>
            <basichttpbinding>
                <binding name="Service1Soap" closetimeout="01:00:00" opentimeout="01:00:00">
                    receiveTimeout="01:00:00" sendTimeout="01:00:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientcredentialtype="None" proxycredentialtype="None">
                            realm="" />
                        <message clientcredentialtype="UserName" algorithmsuite="Default" />
                    </transport></security>
                </readerquotas></binding>
                <binding name="BasicHttpBinding_ICAIS__AdvisiorWebService" closetimeout="01:00:00">
                    openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientcredentialtype="None" proxycredentialtype="None">
                            realm="" />
                        <message clientcredentialtype="UserName" algorithmsuite="Default" />
                    </transport></security>
                </readerquotas></binding>
                <binding name="BasicHttpBinding_ICAIS__AdvisiorWebService1" closetimeout="01:00:00">
                    openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="11655360" maxBufferPoolSize="524288" maxReceivedMessageSize="11655360"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerquotas maxdepth="32" maxstringcontentlength="1181920" maxarraylength="11163840">
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientcredentialtype="None" proxycredentialtype="None">
                            realm="" />
                        <message clientcredentialtype="UserName" algorithmsuite="Default" />
                    </transport></security>
                </readerquotas></binding>
                <binding name="BasicHttpBinding_ICAIS_ManagerWebService1" closetimeout="00:01:00">
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientcredentialtype="None" proxycredentialtype="None">
                            realm="" />
                        <message clientcredentialtype="UserName" algorithmsuite="Default" />
                    </transport></security>
                </readerquotas></binding>
                <binding name="BasicHttpBinding_ITransferService" closetimeout="00:01:00">
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientcredentialtype="None" proxycredentialtype="None">
                            realm="" />
                        <message clientcredentialtype="UserName" algorithmsuite="Default" />
                    </transport></security>
                </readerquotas></binding>
            </basichttpbinding>
        </bindings>
        <client>
 
</client></system.servicemodel></configuration>
  Permalink  
Comments
Kalpesh_Bhadra at 25-Mar-13 0:47am
   
i can upload large file from browser but on desktop application it shows exceptions as followed,
please help me get over it
 

1>
The remote server returned an unexpected response: (400) Bad Request.
 

2>
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:FileAttachment. The InnerException message was 'There was an error deserializing the object of type CAIS_BusinessObjects.CAIS_FileAttachmentBO. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 27123.'. Please see InnerException for more details.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Quote:
Hi Kalpesh,
Your appconfig file has the restriction, change the below parameters as mentioned. And after changing write click your service reference and click Update Service Reference option.

maxBufferSize="65536000" maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000"  maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="8192" maxNameTableCharCount="2147483647"
 
Thanks and regards,
Bluesathish
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 385
1 Sergey Alexandrovich Kryukov 329
2 CPallini 270
3 DamithSL 214
4 Maciej Los 192
0 OriginalGriff 5,515
1 DamithSL 4,451
2 Maciej Los 3,902
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 25 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100