2016-06-22 34 views
0

WCF服務應用程序被配置爲僅接受有限數量的數據大小&大小的數據;我們需要撤消這個限制。我一直在嘗試使用綁定,並且我已經閱讀了StackOverflow上的很多線程以及其他資源。WCF服務應用程序不接受我的綁定

但是,web服務似乎仍然不接受我的綁定並返回錯誤413請求實體到大當我發送大量數據。我老實說WCF服務的經驗很少,所以我的錯誤一定是微不足道的。但幾小時後,我似乎無法知道它是什麼。

另外我不確定在WCF web.config中定義什麼,以及桌面應用程序app.config中屬於什麼,所以也許我錯了。

目前,WCF服務正在本地主機上運行(Visual Studio 2013)。


WPF客戶端應用程序的app.config

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpBinding_IService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed"> 
        <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
       </binding> 
      </basicHttpBinding> 
      <netTcpBinding> 
       <binding receiveTimeout="01:00:00" sendTimeout="01:00:00"> 
        <security mode="None" /> 
       </binding> 
      </netTcpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost:52911/Service.svc" binding="basicHttpBinding" contract="MyWebService.IService" bindingConfiguration="BasicHttpBinding_IService" name="BasicHttpBinding_IService" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

WCF服務應用程序的Web.config

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <appSettings> 
     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
     <compilation debug="true" targetFramework="4.5" /> 
     <httpRuntime targetFramework="4.5" /> 
    </system.web> 
    <system.serviceModel> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior> 
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
        <serviceDebug includeExceptionDetailInFaults="false" /> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <protocolMapping> 
      <add binding="basicHttpsBinding" scheme="https" /> 
     </protocolMapping> 
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true" /> 
     <directoryBrowse enabled="true" /> 
    </system.webServer> 
    <entityFramework> 
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
      <parameters> 
       <parameter value="v11.0" /> 
      </parameters> 
     </defaultConnectionFactory> 
     <providers> 
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
     </providers> 
    </entityFramework> 
    <connectionStrings> 
     <add name="Entities" connectionString="[...]" /> 
    </connectionStrings> 
</configuration> 
+0

嘗試啓用請求實體 –

+0

的流我想它(代碼問題更新),現在我得到一個400錯誤的請求。此外,我仍然不確定什麼屬於哪個配置文件,因爲WPF應用程序的app.config似乎完全被覆蓋。 – bytecode77

+0

@bytecode77,在客戶端,配置節是無用的,因爲你沒有netTcp端點 –

回答

1

在服務器上,你應該配置basicHttpsBinding和/或basicHttpBinding到改變尺寸。

<system.serviceModel>,你應該增加類似:

<bindings> 
    <basicHttpBinding> 
    <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed"> 
     <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
    </binding> 
    </basicHttpBinding> 
    <basicHttpsBinding> 
    <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed"> 
     <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
    </binding> 
    </basicHttpsBinding> 
</bindings> 

注意: 的結合配置有沒有name屬性,因此適用於同一類的每個綁定實例。

問候

+0

它的工作原理!你的回答是如此的緩解。謝謝! – bytecode77