Click here to Skip to main content
15,891,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,


I have a problem to send large amount of data by WCF service.I found a error "The remote server returned an unexpected response: (400) Bad Request"
please anyone send a needful help.

My server side code:

<system.servicemodel>
<bindings>
<wshttpbinding>
<!--<binding name="WSHttpBinding_IService1" closetimeout="00:01:00">
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
maxBytesPerRead="4096" maxNameTableCharCount="16384" />-->


<binding name="WSHttpBinding_IService1" closetimeout="00:10:00">
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647" maxarraylength="2147483647">
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />



<services>
<service name="WcfService.Service1" behaviorconfiguration="WcfService.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="WcfService.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost">


<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">


<behaviors>
<servicebehaviors>
<behavior name="WcfService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<servicemetadata httpgetenabled="true">
<!-- To 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="false">






<system.webserver>
<modules runallmanagedmodulesforallrequests="true">




Client Side Code:

<system.servicemodel>

<bindings>
<wshttpbinding>
<binding name="WSHttpBinding_IService1" closetimeout="00:01:00">
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliablesession ordered="true" inactivitytimeout="00:10:00">
enabled="false" />
<security mode="Message">
<transport clientcredentialtype="Windows" proxycredentialtype="None"> realm="" />
<message clientcredentialtype="Windows" negotiateservicecredential="true">
algorithmSuite="Default" />




<client>
<endpoint address="http://localhost:51470/Service1.svc" binding="wsHttpBinding">
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceRefe_WCF.IService1"
name="WSHttpBinding_IService1">
<identity>
<dns value="localhost">



<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">
<!-- To 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="false">



<servicehostingenvironment multiplesitebindingsenabled="true">


Thanks & Regards
Ram Kumar
Posted

This is a recurring problem with people getting to grips with WCF.

The bit I think you're missing is maxItemsInObjectGraph. But the following article discusses the wider configuration requirements for WCF requests with large amounts of data.


http://stackoverflow.com/questions/8225736/transfer-large-amount-of-data-in-wcf-service[^]
 
Share this answer
 
Comments
Ram Kumar 2009 22-Oct-12 8:06am    
I had change my server side config according to your link.But still i have found a new error "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state"
Stephen Hewison 22-Oct-12 8:08am    
That error message has nothing to do with the object graph size. That error message is a generic error message presented by the client. It means there's a problem with your service and your client can't communicate with it. You need to take a further look at the configuration of your service.
Ram Kumar 2009 22-Oct-12 8:17am    
Hi Stephen,

Thanks for reply again.Now I was not doing any changes in config file and run again this code i had still found "The remote server returned an unexpected response: (400) Bad Request." this error.Can you give me more suggestion...
Stephen Hewison 22-Oct-12 8:28am    
The following is an article about enabling tracing in WCF. Try this, it should provide with more information about your error. http://stackoverflow.com/questions/9897201/how-do-i-investigate-wcf-giving-400-bad-request-over-get
Ram Kumar 2009 22-Oct-12 9:08am    
I have added "system.diagnostics......................... system.diagnostics"
in config file and also added "Error.svclog" viewer but error will be not traced by this.
I found the answer to the Bad Request 400 problem.

It was the default server binding setting. You would need to add to server and client default setting.

binding name="" openTimeout="00:10:00" closeTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900