2016-12-30 70 views
0

我剛剛研究了很多主題,無法找出原因,但我仍然遇到此問題。 我在服務器上的配置。WCF在增加郵件時仍然會收到最大郵件大小錯誤

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/> 
    </appSettings> 
    <system.web> 
    <compilation debug="true"/> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="MyService.Services.Service"> 
     <endpoint behaviorConfiguration="LargeDataBehavior" address="" binding="wsHttpBinding" contract="MyService.Services.UI.IService" bindingConfiguration="MyBinding"> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/MyService.Services/Service/"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <bindings> 
     <wsHttpBinding> 
     <binding bypassProxyOnLocal="True" name="MyBinding" textEncoding="utf-8" 
       maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" 
        maxStringContentLength="2147483647" 
        maxArrayLength="2147483647" 
        maxBytesPerRead="2147483647" 
        maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
      <message clientCredentialType="UserName" algorithmSuite="Default"/> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="LargeDataBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/> 
      <serviceDebug includeExceptionDetailInFaults="True"/> 
      <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

    <startup> 
    <supportedRuntime version="v2.0.50727"/> 
    </startup> 
</configuration> 

然後我運行WCF Test Client。

傳入消息的最大消息大小配額(65536)已被超出。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize屬性。

內部異常: 傳入消息的最大消息大小配額(65536)已被超出。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize屬性。

對不起,我的英語不好。 非常感謝您的幫助!

回答

2

基於錯誤,這聽起來像你需要增加maxReceivedMessageSize屬性在WCFTestClient配置,而不是服務。

爲此,請轉到WCFTestClient左側的底部並右鍵單擊配置文件節點,然後選擇「使用SvcConfigEditor編輯」。

enter image description here

在彈出的窗口中選擇要編輯的結合,並根據需要在右側窗格中,您可以調整所有的值。

enter image description here

注意,這隻會堅持認爲WCFTestClient會議;一旦你關閉它,你會失去設置,它會恢復到默認值。

+0

它適合我。 – vutx

0

似乎配置對服務不正確,因爲在端點級別應用綁定配置後,它仍然給最大大小提供同樣的問題。 您的綁定配置是正確的,但行爲配置應該位於服務級別而不是終點級別。

behaviorConfiguration="newBehaviour"行爲添加到服務級別節點,即'<services>'標記,並且您可以刪除端點標記上的行爲,因爲行爲是服務級別,因此請在服務標記上指定您的行爲配置。

<system.serviceModel> 
    <services name="MyService.Services.Service" behaviorConfiguration="newBehaviour" > 
    <endpoint address="" binding="wsHttpBinding" contract="MyService.Services.UI.IService" bindingConfiguration="MyBinding"> 
      <identity> 
       <dns value="localhost" /> 
      </identity> 
     </endpoint><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
       <add baseAddress="http://localhost:8733/MyService.Services/Service/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <bindings> 
     <wsHttpBinding> 
     <binding bypassProxyOnLocal="True" name="MyBinding" textEncoding="utf-8" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
       <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
       <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="LargeDataBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="newBehaviour"> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" /> 
      <serviceDebug includeExceptionDetailInFaults="True" /> 
      <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 
+0

這不是我的問題傢伙。我做到了,仍然是一樣的錯誤。感謝您的建議。 – vutx

+0

好的,看起來您已將最大大小設置添加到您的客戶端應用程序中,從您使用WCF服務的位置開始,我認爲您還必須將這些設置添加到WCF服務中。 –

相關問題