【问题标题】:Not able to send long string to WCF ,the remote server returned an unexpected response: (400) Bad Request无法向 WCF 发送长字符串,远程服务器返回了意外响应:(400)错误请求
【发布时间】:2014-03-31 11:41:52
【问题描述】:

我正在向服务发送一个很长的字符串,目前是318771 个字符长。 我收到一个错误The remote server returned an unexpected response: (400) Bad Request.

** CLIENT APP.CONFIG **

<bindings>
    <basicHttpBinding>
        <binding name="BasicHttpBinding_INBFC" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="20000000" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="200000000"
                maxArrayLength="200000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>

** SERVICE APP.CONFIG **

<system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
    <pages>
      <namespaces>
        <add namespace="System.Runtime.Serialization"/>
        <add namespace="System.ServiceModel"/>
        <add namespace="System.ServiceModel.Web"/>
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <system.serviceModel>
    <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"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

【问题讨论】:

标签: asp.net .net vb.net web-services wcf


【解决方案1】:

来自W3的畸形请求案例

检查服务是否能够使用 SOAP UI 接收请求,同时检查服务器和客户端调用之间的数据类型是否匹配。

【讨论】:

    【解决方案2】:

    我怀疑您的问题涉及 WCF 绑定配置。特别是maxReceivedMessageSize 值和/或readerQuota 设置。如果您提供客户端/服务器绑定(或配置文件的整个相关部分,我们可以提供更好的指导。)

    注意:您可能希望启用 WCF 跟踪(如果尚未启用),以帮助确定问题的原因。参考:http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

    【讨论】:

    • 您的服务配置没有显示服务定义或服务绑定,因此很难判断服务上的 maxReceivedMessageSize 值和/或 readerQuota 设置是否与客户端匹配。
    猜你喜欢
    • 1970-01-01
    • 2019-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-13
    • 2014-11-27
    • 1970-01-01
    相关资源
    最近更新 更多