2016-06-17 347 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。