2017-03-02 179 views
0

請不要刪除其視爲重複 我有我傳遞對象數組到一個窗口服務。當數組包含少於150個對象時,它可以成功運行。當我傳遞超過150個對象時,(413)請求實體太大錯誤。
我試圖從有關readerQuotas節點值和maxReceivedMessageSize其他物品的反饋,但我仍然收到錯誤,我堅持的是什麼,我還是做錯了。 這裏是窗口服務的app.config:Windows服務(413)請求實體過大

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="basicHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"> 
      <readerQuotas maxDepth="2000000000" 
        maxStringContentLength="2000000000" 
        maxArrayLength="2000000000" 
        maxBytesPerRead="2000000000" 
        maxNameTableCharCount="2000000000" /> 
      </binding> 
     </basicHttpBinding> 
     <wsHttpBinding> 
      <binding name="wsHttpBindingNoSecurity" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> 
       <security mode="None"> 
        <transport clientCredentialType="None"/> 
        <message establishSecurityContext="false" negotiateServiceCredential="false"/> 
       </security> 
       <readerQuotas maxDepth="2000000000" 
        maxStringContentLength="2000000000" 
        maxArrayLength="2000000000" 
        maxBytesPerRead="2000000000" 
        maxNameTableCharCount="2000000000" /> 
      </binding> 
     </wsHttpBinding> 
     <mexHttpBinding> 
      <binding name="mexHttpBinding"/> 
     </mexHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="Service1Behavior"> 
       <serviceMetadata httpGetEnabled="true"/> 
       <serviceDebug includeExceptionDetailInFaults="true"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="SE.Responder.Integration.AmiOutboundService.AmiObService" behaviorConfiguration="Service1Behavior"> 
      <endpoint address="wsHttp" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoSecurity" contract="SE.Responder.Integration.AmiOutboundService.IAmiObService"> 
       <identity> 
        <dns value="localhost"/> 
       </identity> 
      </endpoint> 
      <endpoint address="basicHttp" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" name="basicHttp" contract="SE.Responder.Integration.AmiOutboundService.IAmiObService"/> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
      <host> 
       <baseAddresses> 
        <add baseAddress="http://localhost:8732/SE.Responder.Integration.AmiOutboundService/AmiObService/"/> 
       </baseAddresses> 
      </host> 
     </service> 
    </services> 
</system.serviceModel> 

這裏是可執行的是將數據傳遞到Windows服務的app.config:

<system.serviceModel> 
<bindings> 
    <wsHttpBinding> 
    <binding name="WSHttpBinding_IAmiObService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" > 
     <readerQuotas maxDepth="2000000000" 
        maxStringContentLength="2000000000" 
        maxArrayLength="2000000000" 
        maxBytesPerRead="2000000000" 
        maxNameTableCharCount="2000000000" /> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<client> 
    <endpoint address="http://localhost:8732/SE.Responder.Integration.AmiOutboundService/AmiObService/AmiOBService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAmiObService" contract="AmiObService.IAmiObService" name="WSHttpBinding_IAmiObService" /> 
</client> 

+0

我們將投票關閉爲重複,如果它是一個重複的;如果不是,我們不會。要求我們不要改變這一點。 – Amy

+0

好吧,我用了一個很差的詞。我想說明的是,我已經嘗試了我在其他類似問題中發現的事情,但迄今未取得成功。 –

+0

如果我可以提供一些建議作爲一個長期的時間,所以用戶:當我問的SO一個問題,我試着從我懷疑可能被用作複製其他問題的解決方案,我舉我的問題這些問題隨着簡要說明它所說的做法以及它如何解決我的問題。誠然,這可能會幫助它更快地關閉*,但根據我的經驗,如果我的問題實際上不是重複的,它不會被關閉,這樣做可以幫助我們更快地找到解決方案。 – Amy

回答

0

後回顧有此問題的應用程序的源代碼,我發現wcf服務託管在C#代碼中。如下面的堆棧溢出問題描述我然後施加在碼修復, MaxReceivedMessageSize in WCF Hosted Service in console application, 特別以下行, VAR的wsHttpBinding =新的WSHttpBinding(); wsHttpBinding.MaxReceivedMessageSize = int.MaxValue; Service.AddServiceEndpoint(typeof(TInterfaceContract),wsHttpBinding,EndpointAddress);

它修正了該問題。