First, you can also turn on the WCF service tracing at server-side and collect some trace log to see the detailed error it logged and verify if the message size(or related quota limit) does be the cause of the problem.
For WCF service which need to accept large size data(in request message), there are several settings you need to take care:
* the maxReceivedMessageSize and other related attributes in the <binding> element. And yes, you need to specify the <binding> through "bindingConfiguration" attribute for both your service and client. And the <binding> setting at client
and service sides need to match.
* the <readerQuotas> setting (under <binding> element) which can specify some limitation of the underlying data reader(for processing underlying WCF messsages). e.g.
* the "maxItemsInObjectGraph" attribute in <dataContractSerializer> element. This one is for controlling the underlying DataContractSerializer in case your service will transfer complicated large data object. You can specify it under servicebehavior
element.
* and the <httpRuntime> element which contains the maxRequestLength and executionTimeout attributes. This is necessary when you host your WCF http based service in ASP.NET/IIS environment.
For test purpose, you can set them to the max integer value as other members have suggested. I agree that sometimes such issue is really painful to troubleshoot, but you can try creating a simplified repro and then apply the above settings one by one to
hit the point.
Steven Cheng...
Contributor
4219 Points
548 Posts
Microsoft
Moderator
Re: The remote server returned an unexpected response: (400) Bad Request.
Apr 10, 2012 03:04 AM|LINK
Hi desertfoxaz,
First, you can also turn on the WCF service tracing at server-side and collect some trace log to see the detailed error it logged and verify if the message size(or related quota limit) does be the cause of the problem.
#Service Trace Viewer Tool (SvcTraceViewer.exe)
http://msdn.microsoft.com/en-us/library/ms732023.aspx
#Tracing
http://msdn.microsoft.com/en-us/library/ms730342.aspx
For WCF service which need to accept large size data(in request message), there are several settings you need to take care:
* the maxReceivedMessageSize and other related attributes in the <binding> element. And yes, you need to specify the <binding> through "bindingConfiguration" attribute for both your service and client. And the <binding> setting at client and service sides need to match.
* the <readerQuotas> setting (under <binding> element) which can specify some limitation of the underlying data reader(for processing underlying WCF messsages). e.g.
<basicHttpBinding> <binding name="xxx" maxBufferSize="10000000" maxBufferPoolSize="10000000" maxReceivedMessageSize="10000000"> <readerQuotas maxDepth="10000000" maxStringContentLength="10000000" maxArrayLength="10000000" maxBytesPerRead="10000000" maxNameTableCharCount="10000000" /> </binding>
* the "maxItemsInObjectGraph" attribute in <dataContractSerializer> element. This one is for controlling the underlying DataContractSerializer in case your service will transfer complicated large data object. You can specify it under servicebehavior element.
#DataContractSerializer.MaxItemsInObjectGraph Property http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.maxitemsinobjectgraph.aspx
e.g.
<behaviors> <serviceBehaviors> <behavior name="Umea.se.EventReactor.ServiceTier.ServiceViewEventBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>
* and the <httpRuntime> element which contains the maxRequestLength and executionTimeout attributes. This is necessary when you host your WCF http based service in ASP.NET/IIS environment.
For test purpose, you can set them to the max integer value as other members have suggested. I agree that sometimes such issue is really painful to troubleshoot, but you can try creating a simplified repro and then apply the above settings one by one to hit the point.
Feedback to us
Microsoft One Code Framework