2016-06-17 343 views
0

我已閱讀了許多關於它的帖子,但我不知道我的web.config會發生什麼。WCF:413請求實體太大

這是德的web.config代碼:

<system.serviceModel> 
<client> 
    <endpoint binding="basicHttpBinding" bindingConfiguration="NewBinding0" 
    contract="Service.IService" /> 
</client> 
<bindings> 
    <basicHttpBinding> 
    <binding name="NewBinding0" closeTimeout="00:05:00" openTimeout="00:05:00" 
     sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" 
     maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
    </binding> 
    </basicHttpBinding> 
    <webHttpBinding> 
    <binding name="NewBinding1" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
     maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
    </binding> 
    </webHttpBinding> 
</bindings> 
<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" /> 

我很抱歉,但我不與web.conf文件熟悉。我讀過,我必須設置maxReceivedMessageSize,但我已經完成了,並且我收到了同樣的錯誤。

我正在使用Microsoft Service Configuration Editor編輯文件。 我試過用basicHttpBinding和沒有webHttpBinding,但不起作用。

每次我調用WCF時,都會收到相同的錯誤。

在SOAPUI中嘗試,當郵件大小小於65537時,它起作用。當郵件大小超過65536時,它不起作用。

Thaks提前。

普約爾

+0

[IIS7 - (413)Request Entity Too Large的可能重複| uploadReadAheadSize](http://stackoverflow.com/questions/10122957/iis7-413-request-entity-too-large-uploadreadaheadsize) – stuartd

+0

您是否在服務器和客戶端上都設置了相同的值?他們需要匹配。 –

回答

0

這裏是app.config-

<bindings> 
    <webHttpBinding> 
     <binding name="myBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="Streamed" > 
      <readerQuotas maxDepth="64" maxArrayLength="2147483647" maxStringContentLength="2147483647"/> 
     </binding> 
    </webHttpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="ForecastREST_API.RESTServiceImplBehavior" name="ForecastREST_API.RestServiceImpl"> 
     <endpoint address="http://localhost:59624/RestServiceImpl.svc" binding="webHttpBinding" contract="ForecastREST_API.IRestServiceImpl" behaviorConfiguration="Web" bindingConfiguration="myBinding"> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="webHttpBinding" contract="IMetadataExchange"/> 
    </service> 
</services> 
<behaviors> 
    <endpointBehaviors> 
     <behavior name="Web"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
      <webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" /> 
      <dispatcherSynchronization asynchronousSendEnabled="true" /> 
     </behavior> 
    </endpointBehaviors> 
    <serviceBehaviors> 
     <behavior name="ForecastREST_API.RESTServiceImplBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
    </serviceBehaviors> 
</behaviors> 
0

的maxReceivedMessageSize = 「2147483647」 MAXBUFFERSIZE = 「2147483647」 和bindingConfiguration = 「myBinding」 的工作代碼只在服務端點是非常重要的部分,並且我的項目中還需要bindingName。