![](/img/trans.png)
[英]The remote server returned an unexpected response: (400) Bad Request, WCF
[英]Not able to send long string to WCF ,the remote server returned an unexpected response: (400) Bad Request
我正在向服務發送一個很長的字符串,目前長度為318771
字符。 我收到錯誤The remote server returned an unexpected response: (400) Bad Request.
** 客戶端 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>
W3格式錯誤的請求案例
檢查服務是否能夠使用 SOAP UI 接收請求,同時檢查服務器和客戶端調用之間的數據類型是否匹配。
我懷疑您的問題涉及 WCF 綁定配置。 特別是maxReceivedMessageSize
值和/或readerQuota
設置。 如果您提供客戶端/服務器綁定(或配置文件的整個相關部分,我們可以提供更好的指導。)
注意:您可能希望啟用 WCF 跟蹤(如果尚未啟用)以幫助確定問題的原因。 參考:http ://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.