M
Mohamed Thaufeeq
Guest
I am calling a WCF web service programmatically by generating class files through [`SvcUtil.exe`][1].
All working fine but when I try to send an image (literally a file with size more than 200KB), I get this error.
I know I need to increase `maxReceivedMessageSize` and `maxBufferPoolSize` to the maximum to send large files to the WCF service. Hence, the XML version of doing this will be like below:
<binding name="SampleBinding" allowCookies="true" messageEncoding="Mtom" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="None">
<transport proxyCredentialType="Basic"/>
</security>
</binding>
In this app, since I am using class files generated by SvcUtil, I need to call my WCF service method programmatically.
So I did,
var binding = new BasicHttpBinding();
binding.MaxReceivedMessageSize = binding.MaxBufferPoolSize = long.MaxValue;
binding.AllowCookies = true;
binding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
binding.ReaderQuotas.MaxArrayLength = binding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
binding.ReaderQuotas.MaxStringContentLength = binding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
binding.ReaderQuotas.MaxDepth = int.MaxValue;
webAPI = new WebAPIClient(binding, new EndpointAddress(soapUrl));
The XML version works really well but the C# version failed with below stack trace:
> There was an error on processing web request: Status code
> 413(RequestEntityTooLarge): Request Entity Too Large
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_remoting_wrapper(intptr,intptr)
at (wrapper remoting-invoke) IWebAPI.EndProcessMobileAppRequest(System.IAsyncResult)
at WebAPIClient.EndProcessMobileAppRequest (System.IAsyncResult result) [0x00001] in D:\Projects\MyApp\Utility\ServiceReference\Reference.cs:948
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <58604b4522f748968296166e317b04b4>:0
--- End of stack trace from previous location where exception was thrown ---
at MyApp.Utility.ServiceReference.MyWebApi.ProcessMobileAppRequestAsync (System.String json) [0x0006b] in D:\Projects\MyApp\Utility\ServiceReference\MyWebApi.cs:36
I don't know what's wrong. May you help me?
[1]: ServiceModel Metadata Utility Tool (Svcutil.exe)
- Mohamed Thaufeeq A
Continue reading...
All working fine but when I try to send an image (literally a file with size more than 200KB), I get this error.
I know I need to increase `maxReceivedMessageSize` and `maxBufferPoolSize` to the maximum to send large files to the WCF service. Hence, the XML version of doing this will be like below:
<binding name="SampleBinding" allowCookies="true" messageEncoding="Mtom" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="None">
<transport proxyCredentialType="Basic"/>
</security>
</binding>
In this app, since I am using class files generated by SvcUtil, I need to call my WCF service method programmatically.
So I did,
var binding = new BasicHttpBinding();
binding.MaxReceivedMessageSize = binding.MaxBufferPoolSize = long.MaxValue;
binding.AllowCookies = true;
binding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
binding.ReaderQuotas.MaxArrayLength = binding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
binding.ReaderQuotas.MaxStringContentLength = binding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
binding.ReaderQuotas.MaxDepth = int.MaxValue;
webAPI = new WebAPIClient(binding, new EndpointAddress(soapUrl));
The XML version works really well but the C# version failed with below stack trace:
> There was an error on processing web request: Status code
> 413(RequestEntityTooLarge): Request Entity Too Large
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_remoting_wrapper(intptr,intptr)
at (wrapper remoting-invoke) IWebAPI.EndProcessMobileAppRequest(System.IAsyncResult)
at WebAPIClient.EndProcessMobileAppRequest (System.IAsyncResult result) [0x00001] in D:\Projects\MyApp\Utility\ServiceReference\Reference.cs:948
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <58604b4522f748968296166e317b04b4>:0
--- End of stack trace from previous location where exception was thrown ---
at MyApp.Utility.ServiceReference.MyWebApi.ProcessMobileAppRequestAsync (System.String json) [0x0006b] in D:\Projects\MyApp\Utility\ServiceReference\MyWebApi.cs:36
I don't know what's wrong. May you help me?
[1]: ServiceModel Metadata Utility Tool (Svcutil.exe)
- Mohamed Thaufeeq A
Continue reading...