2014-07-14 74 views
0

我有一个WCF服务,当小数据必须通过线路传输时,它的工作效果很好。当我增加数据到一个更大的尺寸,我得到以下错误:WCF服务:远程服务器返回了意外的响应:(400)错误的请求

The remote server returned an unexpected response: (400) Bad Request. 

我知道这个问题已被问了很多次是其他用户。但是,我尝试了所有这些方法来解决这个问题。没有什么是为我工作的。你能看看我的配置内容,并让我知道如果我失去了一些东西。以下是我的服务的配置文件。

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service name="RecieveValidationResultHubServiceLibrary.ReceiveValidationResultHubService"> 
     <endpoint address="" binding="basicHttpBinding" contract="RecieveValidationResultHubServiceLibrary.IReceiveValidationResultHubService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8735/Design_Time_Addresses/RecieveValidationResultHubServiceLibrary/ReceiveValidationResultHubService/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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> 
    </system.serviceModel> 
</configuration> 

以下是服务引用的配置:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    <add key="MaxParallelThreads" value="300"/> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IReceiveValidationResultHubService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed"/> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8735/Design_Time_Addresses/RecieveValidationResultHubServiceLibrary/ReceiveValidationResultHubService/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReceiveValidationResultHubService" 
     contract="ReceiveValidationServiceReference.IReceiveValidationResultHubService" 
     name="BasicHttpBinding_IReceiveValidationResultHubService" /> 
    </client> 
    <services> 
     <service name="StartValidationClientServiceLibrary.StartValidationClientService"> 
     <endpoint address="" binding="basicHttpBinding" contract="StartValidationClientServiceLibrary.IStartValidationClientService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8734/Design_Time_Addresses/StartValidationClientServiceLibrary/StartValidationClientService/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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> 
    </system.serviceModel> 
</configuration> 
+1

如果知道您尝试了哪些“修复”,这样会很有帮助,因此我们不会在相同的大雁追逐中结束。 –

+0

您可能需要按照[此处](http://stackoverflow.com/questions/884235/wcf-how-to-increase-message-size-quota)的说明放大消息大小配额。 – venerik

+0

我曾尝试: maxBufferPoolSize = “2000000” maxReceivedMessageSize = “2000000” maxStringContentLength = “2000000” 的MaxArrayLength = “2000000” 在两个CONFIGS。但是,没有为我工作。 –

回答

0

如果误差约为最大读者配额,请让你的下结合web.config中的变化。看看它是否有效。

<binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="32" maxStringContentLength="2147483647" 
     maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
</binding> 
+0

我现在的客户端的配置文件看起来是这样的: <绑定名称= “BasicHttpBinding_IReceiveValidationResultHubService” maxBufferPoolSize = “2147483647” maxReceivedMessageSize = “2147483647” MAXBUFFERSIZE = “2147483647” transferMode = “流”> 我仍然不知道在哪里把这些最大PARAMS在我的服务的配置文件。 –

+0

在你的web.config文件中,有标签,里面有标签。在标记中使用此代码。 – Aki

相关问题