Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

WCF service - MaxReceivedMessageSize property

Posted on 2012-09-20
8
Medium Priority
?
2,508 Views
Last Modified: 2012-10-10
I got a message about MaxReceivedMessageSize, when I invoke a WCF service in WCF Test Client.  I think the dataset the Service return is bigger than others.  How to solve this problem?  Can you provide some sample code?

"Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service."

"The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."
0
Comment
Question by:5281
  • 4
  • 3
8 Comments
 
LVL 14

Assisted Solution

by:Vel Eous
Vel Eous earned 375 total points
ID: 38421196
You can increase the MaxReceivedMessageSize in code as follows:

var binding = new WsHttpBinding(); // replace this with your preferred binding
binding.MaxReceivedMessageSize = Int32.MaxValue * 4;
var WcfClient = new WcfService(binding, serviceUrl);

Open in new window


Or you can do it in the App.config file:

<system.ServiceModel>
	<bindings>
		<wsHttpBinding>
			<binding name="wsHttpBindingSettings" maxReceivedMessageSize="2147483647" />
		</wsHttpBinding>
	</bindings>
</system.ServiceModel>

Open in new window

0
 

Author Comment

by:5281
ID: 38421562
I added your second sample into web.config file, but it still gave that same error message when I invoke the WCF server.
0
 
LVL 11

Expert Comment

by:Kelvin McDaniel
ID: 38421817
If I remember correctly (it's been a while) the same setting also needs to be on the client side and the value needs to match what's in the service definition.

I'd caution against using such a huge value... in effect, you're giving the "all clear" for the service to send back a 2GB message.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:5281
ID: 38421906
azarc3,

Do you mean the same setting also needs to be on the server side?  I am working on my local IIS server (localhost), how can I change my localhost setting?

That service returns a dataset, I don't understand why it is called "message" here.
0
 
LVL 11

Expert Comment

by:Kelvin McDaniel
ID: 38421919
WCF services pass serialized strings, so the common term used across various technologies is "message". We are saying the same thing.  :)

Yes, the same setting needs to be on both the service website and the consuming website. They may be one in the same, so the section of the web.config that deals with each part needs to have the same setting.
0
 

Author Comment

by:5281
ID: 38421964
Do you mean I should ignore the error message gave in WCF Test Client?  It will be ok as long as both web.config files include above setting?  

My consuming website is not a wcf project, it is a regular asp.net 1.1 web application, how to specify the setting in a asp.net 1.1 application?
0
 
LVL 11

Accepted Solution

by:
Kelvin McDaniel earned 375 total points
ID: 38422055
Ok, that explains a little bit. Unfortunately I haven't tried to use WCF with anything below an asp.net 2.0 app, so my advice will be a little limited.

However, here is the portion of an older consuming app's web.config that sets the max received message size.

<system.serviceModel>
	<behaviors>
		<serviceBehaviors>
			<behavior name="">
				<serviceMetadata httpGetEnabled="true"/>
				<serviceDebug includeExceptionDetailInFaults="false"/>
			</behavior>
		</serviceBehaviors>
	</behaviors>
	<bindings>
		<basicHttpBinding>
			<binding name="BasicHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="10240000" maxBufferPoolSize="81920000" maxReceivedMessageSize="10240000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
				<readerQuotas maxDepth="32" maxStringContentLength="10240000" maxArrayLength="20480000" maxBytesPerRead="5120000" maxNameTableCharCount="20480000"/>
				<security mode="None">
					<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
					<message clientCredentialType="UserName" algorithmSuite="Default"/>
				</security>
			</binding>
		</basicHttpBinding>
	</bindings>
	<services>
		...
	</services>
	<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
	<client>
		...
	</client>
</system.serviceModel>

Open in new window


The size in the code above is the most recent change we've had to make to acccomodate the same problem you're having.
0
 

Author Comment

by:5281
ID: 38423497
Tchuki,

The code you provide about MaxReceivedMessageSize, should it be put in WCF service application or consuming application?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question