My WCF client works OK with WCF server except when making a call to the server trying to pass Datatable of custom objects. When the datarow count is 300 items it works fine, but when number of items is 500 the server throws exception Bad Request (400). So
I assume that the key to the solution is in configuration file,
The configuration file looks to have enough timeout as well as MaxReceivedMessageSize. You can try increasing the
MaxReceivedMessageSize and maxStringContentLength to see if that helps, but you will continue to have a problem by sending so much data.
Read this for more information about addressing this error:
This config file is just for the client (see Client node).. There is no service node which is required on the server. You also need to increase the settings on the server. have you changed the web.config file on the server?
sureshkumarp...
Member
1 Points
62 Posts
the remote server returned an unexpected response: (400) Bad Request.
Nov 06, 2012 02:08 PM|LINK
Hi ,
My WCF client works OK with WCF server except when making a call to the server trying to pass Datatable of custom objects. When the datarow count is 300 items it works fine, but when number of items is 500 the server throws exception Bad Request (400). So I assume that the key to the solution is in configuration file,
Config,
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISECURITY" closeTimeout="00:25:00"
openTimeout="00:25:00" receiveTimeout="00:25:00" sendTimeout="00:25:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:3967/DQ_SERVICES.svc/SECURITY"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISECURITY"
contract="DQ.SERVICES.ISECURITY" name="BasicHttpBinding_ISECURITY" />
</client>
Exception,
the remote server returned an unexpected response: (400) Bad Request.
Stack,
"\r\nServer stack trace: \r\n at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException)\r\n at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)\r\n at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)\r\n at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)\r\n at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\r\n at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)\r\n at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\r\n at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\r\n\r\nException rethrown at [0]: \r\n at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\r\n at Web.Core.Ilrt.DQ.SERVICES.IOFFER.DQ_SetCriteriaSet(DQ_SetCriteriaSetRequest Request, DQ_SecToken Token)\r\n at Web.Core.Ilrt.DQ.SERVICES.OFFERClient.DQ_SetCriteriaSet(DQ_SetCriteriaSetRequest Request, DQ_SecToken Token) in D:\\Consolidated DQ_Screens\\WebSolution\\DQWEB\\Web.Core.Ilrt\\Service References\\DQ.SERVICES\\Reference.cs:line 38978\r\n at Web.Core.Ilrt.CommonFuncions.SetCriteriaSet(DQ_SecToken Token, String driverid, String drivername, String driverEffDate, String driverExpdate, String driverstatus, String drivertca, String drivercycle, String driverclientid, String driveroverride, String driversetups, String categoryid, String categoryname, String categoryflag, String categoryexpdate, String categoryindex, DataTable offeritemandofferitemset, DataTable criteriaset, String& ErrorID, String& ErrorMessage) in D:\\Consolidated DQ_Screens\\WebSolution\\DQWEB\\Web.Core.Ilrt\\IlProxy.cs:line 3225"
Please provide some solution to resolve this issue.
Regards,
Suresh
ozkary
Contributor
2034 Points
303 Posts
Re: the remote server returned an unexpected response: (400) Bad Request.
Nov 07, 2012 01:55 AM|LINK
The configuration file looks to have enough timeout as well as MaxReceivedMessageSize. You can try increasing the MaxReceivedMessageSize and maxStringContentLength to see if that helps, but you will continue to have a problem by sending so much data.
Read this for more information about addressing this error:
http://ozkary.blogspot.com/2011/03/wcf-service-returns-400-bad-request.html
I would recommend segmenting such large request to allow your service to perform better.
hope that helps.
og-bit.com
sureshkumarp...
Member
1 Points
62 Posts
Re: the remote server returned an unexpected response: (400) Bad Request.
Nov 07, 2012 04:30 AM|LINK
HI ,
Already i given max value for below properties,
MaxReceivedMessageSize="2147483647"
maxStringContentLength ="2147483647"
what else i have to change in config file,
This issue we can fix make changes in config file only but already i have done all the chages
what else i have to change in config file,
Please provide some soltion for this issue,
Regards,
Suresh
Haixia Xie -...
Contributor
3031 Points
296 Posts
Microsoft
Re: the remote server returned an unexpected response: (400) Bad Request.
Nov 08, 2012 01:00 AM|LINK
Hi sureshkumarparamas,
Please make sure the sendTimeout of the client are big enough, try increase reader quota values from binding configuration on both sides.
Best Regards.
Feedback to us
Develop and promote your apps in Windows Store
sureshkumarp...
Member
1 Points
62 Posts
Re: the remote server returned an unexpected response: (400) Bad Request.
Nov 08, 2012 04:42 AM|LINK
Hi,
I have updated my reader quota even also i am getting same error,
FYR , Config file entries,
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="TestGraphRange1">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISECURITY" closeTimeout="00:25:00"
openTimeout="00:25:00" receiveTimeout="00:25:00" sendTimeout="00:25:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:3967/DQ_SERVICES.svc/SECURITY"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISECURITY"
behaviorConfiguration="TestGraphRange1"
contract="DQ.SERVICES.ISECURITY" name="BasicHttpBinding_ISECURITY" />
</client>
</system.serviceModel>
</configuration>
what else i have to do resolving this issue. Please provide some solution to resolve this issue.
Regards,
Suresh
ozkary
Contributor
2034 Points
303 Posts
Re: the remote server returned an unexpected response: (400) Bad Request.
Nov 08, 2012 01:00 PM|LINK
This config file is just for the client (see Client node).. There is no service node which is required on the server. You also need to increase the settings on the server. have you changed the web.config file on the server?
og-bit.com
sureshkumarp...
Member
1 Points
62 Posts
Re: the remote server returned an unexpected response: (400) Bad Request.
Nov 15, 2012 12:17 PM|LINK
Hi ,
I have updated necessary properties in Web.Config file, even also issue getting reproduced again.
Message like,
" The remote server returned an unexpected response: (400) Bad Request."
Please provide some solution to resolve this issue.
Regards,
Suresh