远程服务器返回了意外响应400 Bad Request

本文转自:http://bbs.51aspx.com/showtopic-42348.html

 

远程服务器返回了意外响应 400 Bad Request。原因在于:传输的数据量过大。
解决方案:
首先在客户端(client)的配置文件里:
1.在节点<binding>修改传输数据的最大额度:

  1. <system.serviceModel>
  2.     <bindings>
  3.       <basicHttpBinding>
  4.         <binding name="BasicHttpBinding_USService1" closeTimeout="00:03:00"
  5.           openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00"
  6.           allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
  7.           maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
  8.           messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
  9.           useDefaultWebProxy="true">
  10.           <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
  11.             maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
  12.           <security mode="None">
  13.             <transport clientCredentialType="None" proxyCredentialType="None"
  14.               realm="" />
  15.             <message clientCredentialType="UserName" algorithmSuite="Default" />
  16.           </security>
  17.         </binding>
  18.       </basicHttpBinding>
  19.     </bindings>
  20.     <client>
  21.       <endpoint address="http://localhost:8001/usinfoservices" binding="basicHttpBinding"
  22.         bindingConfiguration="BasicHttpBinding_USService1" contract="ServiceReference2.USService"
  23.         name="BasicHttpBinding_USService1" />
  24.     </client>
  25.   </system.serviceModel>
  26. 然后在修改服务器端<Hosting>的配置文件:
  27. 1.在节点<binding>修改传输数据的最大额度:
  28. <system.serviceModel>
  29.        <bindings>
  30.          <basicHttpBinding>
  31.            <binding name="newBinding" maxBufferPoolSize="21474835647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
  32.               <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
  33.            </binding>
  34.           </basicHttpBinding>
  35.        </bindings>
  36.         <behaviors>
  37.           <serviceBehaviors>
  38.             <behavior name="metadataBehavior">
  39.                 <serviceMetadata httpGetEnabled="true" />
  40.                 <serviceDebug includeExceptionDetailInFaults="true"/>
  41.             </behavior>  
  42.          </serviceBehaviors>  
  43.         </behaviors>        
  44.         <services>
  45.           <service behaviorConfiguration="metadataBehavior" name="Genesysinfo.USServices.Services.USInfoServices">
  46.              <endpoint address="" bindingConfiguration="newBinding" binding="basicHttpBinding" contract="Genesysinfo.USServices.Contracts.IUSInfoServices" />
  47.              <endpoint address="" binding="netTcpBinding" contract="Genesysinfo.USServices.Contracts.IUSInfoServices" />
  48.              <host>
  49.                 <baseAddresses>
  50.                     <add baseAddress="http://localhost:8001/usinfoservices" />
  51.                     <add baseAddress="net.tcp://localhost:8000/usinfoservices" />
  52.                 </baseAddresses>
  53.              </host>
  54.             <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
  55.           </service>        
  56.         </services>  
  57.      </system.serviceModel>
复制代码

就OK了。

你可能感兴趣的:(request)