![](/img/trans.png)
[英]Where to put MaxReceivedMessageSize property in WCF service's web.config file?
[英]Configuration of a Wcf Service: Web.config maxReceivedMessageSize not working (Even with edit wcf Configuration)
為了輕松重現該錯誤,我創建了一個名為TestService的新wcf服務。
當我執行9999次循環時,收到所需的消息:超出了傳入消息的最大消息大小配額(65536)。
因此,我更改了其他stackoverflow踏板上描述的必需內容。 但沒有成功...然后我使用工具Wcf Service找到了本手冊( http://keithelder.net/2008/01/17/exposed-a-wcf-service-with-multiple-bindings-and-endpoints/ )配置。 但同樣的錯誤。
這是配置:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttp" maxBufferPoolSize="9999999" maxBufferSize="9999999"
maxReceivedMessageSize="9999999" />
</basicHttpBinding>
</bindings>
<services>
<service name="TestService.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttp"
name="BasicHttp" contract="TestService.IService1" />
</service>
</services>
<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" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
如果您想要的代碼。 很高興分享。 雖然這只是一個填充字符串列表的循環。
編輯:我已經添加到新服務,所以我可以有一個客戶端配置。 問題仍然存在。
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="TestService2.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttp"
name="BasicHttp" contract="TestService2.IService1" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttp" maxBufferSize="65536999" maxReceivedMessageSize="65536999">
<readerQuotas maxStringContentLength="65536999" maxArrayLength="65536999" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:58526/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttp" contract="ServiceReference1.IService1"
name="BasicHttp" />
</client>
<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" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
您必須確保客戶端和服務器配置文件都具有適當的值,例如:對於服務器端(不帶名稱的綁定):
<basicHttpBinding>
<binding
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="1024"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
這也是行為:
<behaviors>
<serviceBehaviors>
<behavior name="ECMSServiceBehavior">
<dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
對於客戶端:
<basicHttpBinding>
<binding
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="1024"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
希望能幫助到你。
客戶端配置中存在問題。 檢查客戶端配置。 服務器端配置似乎很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.