I have an ASP.NET web application where i am using WCF 4 REST services to insert and get data from the database. But when trying to insert large amount of data like data for 1000 employees i am getting the error 'Unexpected End of File'.
Can anyone suggest a solution. Thanks in advance.
Have you tried setting the Max sizes in the web.config on the WCF services and possibly in the App/Web config file on the client side. It needs to look something like this:
<binding name="NewBinding0" sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
This should work for REST service.
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint helpEnabled="true" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647" automaticFormatSelectionEnabled="true">
<security mode="None"/>
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
Related
My client application is calling a web service, everything works fine, except a function call always throw this error (The maximum message size quota for incoming messages (33554431) has been exceeded.)
I have tried to increase the maxBufferSize in the app.config file of my client application to 335544310, but it did not help solving this problem.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpsEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="33554431" maxBufferPoolSize="33554431" maxReceivedMessageSize="33554431" messageEncoding="Text" textEncoding="utf-8"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="33554431" maxArrayLength="33554431" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://api.smartmailpro.com/2.0/API.svc" binding="basicHttpBinding" bindingConfiguration="basicHttpsEndpoint" contract="SmartMailProApi.API" name="basicHttpsEndpoint" />
</client>
</system.serviceModel>
I suspect that there are two possibilities
1) The value that I am using is too large
2) I need to perform the same update to the server web services as well
Could anyone point me to the right direction, please?
What are the real purposes of following three parameters :
maxBufferSize="33554431"
maxBufferPoolSize="33554431"
maxReceivedMessageSize="33554431"
Enlarge the value of the maxBufferSize to 2147483647, and solved the problem.
I have a WCF web service which is hosted at a .svc file by ASP.NET. .svc file contains following configuration:
<%# ServiceHost Language="C#" Debug="true" Service="assembly.IPriceListProvider, assembly" Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" %>
web.config contains configuration of the WCF. Here goes the binding configuration:
<binding name="basicHttpBinding_PriceListProvider" maxBufferSize="10485760"
maxReceivedMessageSize="10485760">
<readerQuotas maxArrayLength="16384000" />
</binding>
To test the service, I click on .svc file and click F5. WCF Test Client is opened. But the configuration has changed. The values which I've explicitly defined have now default values:
<binding name="basicHttpBindingEndPoint_PriceListProvider" 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" />
</security>
</binding>
Why does the configuration change? How do I persist original values?
I've heard something about simplified .svc configuration: a default binding for .svc is configured even if you don't specify it explicitly in web.config. Can it be the case?
The values for maxBufferSize and maxReceivedMessageSize are not propagated to the WSDL file that is published by your service. That´s why the wcf test client is unable to retrieve them and takes default values.
You can still change the values with the SvcConfigEditor every time you start the wcf test client. Therefor perform a right click on the config file in the wcf test client and look for bindings. But the changes will be lost, the next time you start the client.
You can also test your service with a self written client and set the values there like shown in the following example.
BasicHttpBinding binding= new BasicHttpBinding();
binding.MaxRecievedMessageSize = yourValue;
EndpointAddress endpointAddress = new EndpointAddress("the address");
ClientForContract client= new ClientForContract (binding,endpointAddress);
client.TheMethod();
client.Close();
Hope this helps!
I am trying to implement attachment functionality in one of my web application. It has three layer. Presentation, Business and Service Layer and i have blob datatype in database of attachment field....i am getting below Error while transferring data from business layer to service layer.
The remote server returned an unexpected response: (400) Bad Request
I cant find any solution even i tried with increase arraylength, buffersize etc...But still getting error...So if anyone have any idea than please help me....I am facing this issue since 5 days.....
Here is my web.config settings
<binding name="BasicHttpBinding_ITestService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="83886080" maxBufferPoolSize="83886080" maxReceivedMessageSize="83886080"
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" />
</security>
</binding>
turn on WCF tracing on server side by adding following section to WCF host's configuration file. you will be able to get more specific reason for your failure from the trace file.
<system.diagnostics>
<trace autoflush="false"/>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\ServiceTrace.svclog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
You need to use WCF streaming for the purpose of uploading large files. But still there are some limits for the approach being used. So transferring large files over HTTP needs a lot of considerations.
Detailed examples and consideration has been posted already at following links.
http://garfoot.com/blog/2008/06/transferring-large-files-using-wcf/
http://kjellsj.blogspot.com/2007/02/wcf-streaming-upload-files-over-http.html
need to use WCF streaming for the purpose of uploading large files. But still there are some limits for the approach being used. So transferring large files over HTTP needs a lot of considerations. Detailed examples and consideration has been posted already at following links. http://garfoot.com/blog/2008/06/transferring-large-files-using-wcf/
http://kjellsj.blogspot.com/2007/02/wcf-streaming-upload-files-over-http.html
Well, i can't solve the following problem.
I have the next:
* A Web Service development in C# + .Net Framework 3.5 + iBatis (VS2010) with some WebMethods.
* The Web Service run on a local server, in IIS 5.1 (http://localhost/BookService/BookService.asmx).
* An application WF+C# + .Net Framework 3.5 (VS2010) where the BO layer have a service reference to the Web Service.
The app.config generated by Service Reference is:
<?xml version="1.0" encoding="utf-8" ?>´
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BookServiceSoap" 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" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://10.0.2.15/BookService/BooksService.asmx"
binding="basicHttpBinding" bindingConfiguration="BookServiceSoap"
contract="BookService.BookServiceSoap" name="BookServiceSoap" />
</client>
</system.serviceModel>
</configuration>
I'm trying to connecting me to the web service making for example
BookService.BookServiceSoapClient query = new BookService.BookServiceSoapClient("BookServiceSoap","http://10.0.2.15/BookService/BookService.asmx");
or with out the endpointname and the url
BookService.BookServiceSoapClient query = new BookService.BookServiceSoapClient();
But in execution time appears the following message
Could not find endpoint element with name 'BookServiceSoap'
and contract 'BookService.BookServiceSoap' in the ServiceModel
client configuration section. This might be because no
configuration file was found for your application, or because
no endpoint element matching this name could be found in the client element.
Can somebody show me un right example to call for example the method HelloWorld.
Regards!
I have developed one console application and from there i have called WCF function after adding as web reference. my console application's web.config as per below..
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01: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="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://apicaWCF.cloudapp.net/ApicaAzureMonitorAgentReceiverWCF.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"
contract="Dashboard2WCFData.IApicaAzureMonitorAgentReceiverWCF"
name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF" />
</client>
I am getting error : The size necessary to buffer the XML content exceeded the buffer quota. I have also tried it and increased maxbuffersize and etc. still could not resolved this. hope anyone can here help me to sort out this issue.
Thanks.
Arun
Finally i got solution , the problem was with stored procedure parameter data type and got this solution using attaching process mechanism in visual studio, so i have debug the wcf function from console application and got exact error in WCF catch block.