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

远程服务器返回了意外响应 400 Bad Request。原因在于:传输的数据量过大。

解决方案:

首先在客户端(client)的配置文件里:

1.在节点<binding>修改传输数据的最大额度:

    <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_USService1" closeTimeout="00:03:00"
          openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" 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:8001/usinfoservices" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_USService1" contract="ServiceReference2.USService"
        name="BasicHttpBinding_USService1" />
    </client>
  </system.serviceModel>

然后在修改服务器端<Hosting>的配置文件:

1.在节点<binding>修改传输数据的最大额度:

 <system.serviceModel>
       <bindings>
         <basicHttpBinding>
           <binding name="newBinding" maxBufferPoolSize="21474835647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
           </binding>
          </basicHttpBinding>
       </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="metadataBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>   
         </serviceBehaviors>  
        </behaviors>         
        <services>
          <service behaviorConfiguration="metadataBehavior" name="Genesysinfo.USServices.Services.USInfoServices">
             <endpoint address="" bindingConfiguration="newBinding" binding="basicHttpBinding" contract="Genesysinfo.USServices.Contracts.IUSInfoServices" />
             <endpoint address="" binding="netTcpBinding" contract="Genesysinfo.USServices.Contracts.IUSInfoServices" />
             <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:8001/usinfoservices" />
                    <add baseAddress="net.tcp://localhost:8000/usinfoservices" />
                </baseAddresses>
             </host>
            <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
          </service>        
        </services>  
     </system.serviceModel>

 

就OK了。

 

转载于:https://www.cnblogs.com/xuebingz/archive/2011/12/15/2289058.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值