• WCF:(400) Bad Request


    报错信息:远程服务器返回了意外响应: (400) Bad Request。

    经过几次调试,发现小数据量不会出现此错误,如何传输大数据量呢,经过网上搜索和几次测试发现,只要在服务端和客户端同时增大以下几个配置项。

    服务器端:

    <system.serviceModel>
        
    <bindings>
          
    <basicHttpBinding>
            
    <binding maxBufferPoolSize="5242880000" maxBufferSize="655360000" maxReceivedMessageSize="655360000">
              
    <security mode="None"/>
            
    </binding>
          
    </basicHttpBinding>
        
    </bindings>
        
    <services>
          
    <service name="test">
            
    <endpoint binding="basicHttpBinding" name="test" contract="Test_Service.Test"/>
          
    </service>
        
    </services>

        
    <behaviors>
          
    <serviceBehaviors>
            
    <behavior>
              
    <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
              
    <serviceMetadata httpGetEnabled="true"/>
              
    <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
              
    <serviceDebug includeExceptionDetailInFaults="true"/>
            
    </behavior>
          
    </serviceBehaviors>
        
    </behaviors>
        
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      
    </system.serviceModel>

    同样在客户端也需要增大与服务器端相同的配置:

    <system.serviceModel>
        
    <bindings>
          
    <basicHttpBinding>
            
    <binding name="BasicHttpBinding_ITest" closeTimeout="00:01:00"
                    openTimeout
    ="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies
    ="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize
    ="655360000" maxBufferPoolSize="5242880000" maxReceivedMessageSize="655360000"
                    messageEncoding
    ="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy
    ="true">
              
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead
    ="4096" maxNameTableCharCount="16384" />
              
    <security mode="None">
                
    <transport clientCredentialType="None" proxyCredentialType="None"
                  realm
    ="" />
                
    <message clientCredentialType="UserName" algorithmSuite="Default" />
              
    </security>
            
    </binding>
          
    </basicHttpBinding>
        
    </bindings>
        
    <client>
          
    <endpoint address="http://www.test.com/Test.svc"
            binding
    ="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITest"
            contract
    ="TestService.ITest" name="BasicHttpBinding_ITest" />
        
    </client>
      
    </system.serviceModel>
  • 相关阅读:
    MyBatis框架Dao代理
    MyBatis对象分析及创建工具类
    搭建MyBatis开发环境及基本的CURD
    IDEA中配置Maven
    rpm 安装mysql8.0 ;安装deb
    SpringBoot 整合 xxl-job 指导手册
    设计模式(一) 单例设计模式
    SpringCloud (三) Eureka 注册中心
    SpringCloud (二) 注册中心理论
    SpringCloud (一) 微服务入门
  • 原文地址:https://www.cnblogs.com/guanjie20/p/2009510.html
Copyright © 2020-2023  润新知