2014-03-31 45 views
-1

我正在發送一個非常長的字符串服務,目前是318771字符長。 我得到一個錯誤The remote server returned an unexpected response: (400) Bad Request.無法發送長字符串到WCF,遠程服務器返回意外的響應:(400)錯誤的請求

**客戶端的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> 

**服務的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> 
+0

可能重複[遠程服務器返回意外的響應:(400)錯誤的請求](http://stackoverflow.com/questions/1651143/the-remote-server-returned-an-unexpected-response -400-bad-request) – CodeCaster

回答

0

惡意請求從W3

案例

檢查服務是否能夠使用SOAP UI接收請求,並檢查服務器和客戶端調用之間的數據類型是否匹配。

0

我懷疑你的問題涉及WCF綁定配置。尤其是,maxReceivedMessageSize值和/或readerQuota設置。如果您提供客戶端/服務器綁定(或配置文件的所有相關部分,我們可以提供更好的指導)。

注意:如果您尚未啓用WCF跟蹤,可能需要幫助確定問題的原因。參考:http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

+0

請參閱我的更新 – Arbaaz

+0

您的服務配置未顯示服務定義或服務綁定,因此很難判斷服務上的maxReceivedMessageSize值和/或readerQuota設置是否與客戶端匹配。 – Seymour

相關問題