wcf配置 MaxReceivedMessageSize 问题
最近调用wcf互操作时服务端提示如下信息:The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
应该是说 序列化后传输的数据量大于65536,要设置 MaxReceivedMessageSize 扩大可传输的数据量,但是这个属性我在客户端服务端都配置过了,具体如下
WCF服务端配置在IIS6中,win2k3 sp2系统,
配置如下:
<bindings>
<basicHttpBinding>
<binding name='basicHttpBindingConfig' maxBufferSize='2147483647'
maxBufferPoolSize='2147483647' maxReceivedMessageSize='2147483647'
messageEncoding='Mtom' transferMode='Streamed'>
<readerQuotas maxDepth='2147483647'
maxStringContentLength='2147483647'
maxArrayLength='2147483647'
maxBytesPerRead='2147483647'
maxNameTableCharCount='2147483647'/>
</binding>
</basicHttpBinding>
</bindings>
在客户端是用代码进行配置的,如下:
m_BasicHttpBindingConfig = new BasicHttpBinding
{
Name = "basicHttpBindingConfig",
MaxBufferSize = 2147483647,
MaxBufferPoolSize = 2147483647,
MaxReceivedMessageSize = 2147483647,
//MessageEncoding = WSMessageEncoding.Mtom,
TransferMode = TransferMode.Streamed,
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas
{
MaxDepth = 2147483647,
MaxStringContentLength = 2147483647,
MaxArrayLength = 2147483647,
MaxBytesPerRead = 2147483647,
MaxNameTableCharCount = 2147483647
},
Security = new BasicHttpSecurity
{
Mode = BasicHttpSecurityMode.None,
Transport = new HttpTransportSecurity
{
ClientCredentialType = HttpClientCredentialType.None,
ProxyCredentialType = HttpProxyCredentialType.None,
Realm = ""
},
Message = new BasicHttpMessageSecurity
{
ClientCredentialType = BasicHttpMessageCredentialType.UserName,
AlgorithmSuite = SecurityAlgorithmSuite.Default
}
},
SendTimeout = new TimeSpan(0, 30, 0)
};
两个问题:
1) 其中的maxReceivedMessageSize都是配置过的,但是调用时数据量增大时还是会报超65536的错,难道是IIS或OS的问题么?
2) 另外,还有一个问题是,明明服务端已经配置过 messageEncoding='Mtom' ,客户端代码配置 //MessageEncoding = WSMessageEncoding.Mtom 编译是没错,但是运行是根本无法和wcf服务端进行交互的,这个太奇怪了,不得解啊
--------------------编程问答-------------------- 又看了一下trace log,上面在报maxReceivedMessageSize之前,还有一个警告:
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>524312</EventID>
<Type>3</Type>
<SubType Name="Warning">0</SubType>
<Level>4</Level>
<TimeCreated SystemTime="2012-12-24T06:33:07.5293604Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{21907a84-e748-4e8e-8b91-92d21c9e25cc}" />
<Execution ProcessName="w3wp" ProcessID="2828" ThreadID="6" />
<Channel />
<Computer>BXSERVER</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning">
<TraceIdentifier>http://msdn.microsoft.com/zh-CN/library/System.ServiceModel.EvaluationContextNotFound.aspx</TraceIdentifier>
<Description>Configuration evaluation context not found.</Description>
<AppDomain>/LM/W3SVC/803627/Root/EPS.Business.WCF-3-130008043855298980</AppDomain>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
说没找到配置评估上下文,这样是不是我写的配置就一直没起作用啊?
配置应该不会有问题吧?配置如下:
--------------------编程问答-------------------- http://blog.csdn.net/fangxinggood/article/details/6031072 --------------------编程问答-------------------- 第一个问题你搞定了?
<?xml version='1.0' encoding='utf-8' ?>
<configuration>
<configSections>
<sectionGroup name='applicationSettings' type='System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' >
<section name='TTS.WCF.Properties.Settings' type='System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' requirePermission='false' />
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<source name='System.ServiceModel.MessageLogging' switchValue='Warning, ActivityTracing'>
<listeners>
<add type='System.Diagnostics.DefaultTraceListener' name='Default'>
<filter type='' />
</add>
<add name='ServiceModelMessageLoggingListener'>
<filter type='' />
</add>
</listeners>
</source>
<source name='System.ServiceModel' switchValue='Warning, ActivityTracing'
propagateActivity='true'>
<listeners>
<add type='System.Diagnostics.DefaultTraceListener' name='Default'>
<filter type='' />
</add>
<add name='ServiceModelTraceListener'>
<filter type='' />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData='C:\app_messages.svclog'
type='System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
name='ServiceModelMessageLoggingListener' traceOutputOptions='Timestamp'>
<filter type='' />
</add>
<add initializeData='C:\app_tracelog.svclog'
type='System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
name='ServiceModelTraceListener' traceOutputOptions='Timestamp'>
<filter type='' />
</add>
</sharedListeners>
<trace autoflush='true' />
</system.diagnostics>
<system.web>
<compilation debug='true' />
<httpRuntime maxRequestLength='2097151'/>
</system.web>
<!-- 部署服务库项目时,必须将配置文件的内容添加到
主机的 app.config 文件中。System.Configuration 不支持库的配置文件。-->
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages='true' logMessagesAtTransportLevel='true' />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name='basicHttpBindingConfig' maxBufferSize='2147483647'
maxBufferPoolSize='2147483647' maxReceivedMessageSize='2147483647'
messageEncoding='Mtom' transferMode='Streamed'>
<readerQuotas maxDepth='2147483647'
maxStringContentLength='2147483647'
maxArrayLength='2147483647'
maxBytesPerRead='2147483647'
maxNameTableCharCount='2147483647'/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<!-- BusinessDepartmentService-->
<service name='EPS.EntityCollection.Business.BusinessDepartmentService'>
<endpoint address='' binding='basicHttpBinding' bindingConfiguration='basicHttpBindingConfig'
name='BusinessDepartmentService' contract='EPS.EntityCollection.Business.IBusinessDepartmentService'>
</endpoint>
<endpoint address='mex' binding='mexHttpBinding' contract='IMetadataExchange' />
<host>
<baseAddresses>
<add baseAddress='http://192.168.1.1/TTS.WCF/BusinessDepartmentService.svc' />
</baseAddresses>
</host>
</service>
<!-- BusinessPostService-->
<service name='EPS.EntityCollection.Business.BusinessPostService'>
<endpoint address='' binding='basicHttpBinding' bindingConfiguration='basicHttpBindingConfig'
name='BusinessPostService' contract='EPS.EntityCollection.Business.IBusinessPostService'>
</endpoint>
<endpoint address='mex' binding='mexHttpBinding' contract='IMetadataExchange' />
<host>
<baseAddresses>
<add baseAddress='http://192.168.1.1/TTS.WCF/BusinessPostService.svc' />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,
请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled='True'/>
<!-- 要接收故障异常详细信息以进行调试,
请将以下值设置为 true。在部署前设置为 false
以避免泄漏异常信息-->
<serviceDebug includeExceptionDetailInFaults='true' />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
第二个问题:
参考这个
http://stackoverflow.com/questions/3636341/configuration-evaluation-context-not-found-warning-on-wcf-trace
The evaluation context not found error (or in traces with the identifier System.ServiceModel.EvaluationContextNotFound) is generally caused by using a configuration element defined in a library that is not included in the application’s configuration as an extension. --------------------编程问答--------------------
还是不行,报一样的错.
我再部署了一下,测试后发现在trace log最开头有一个警告:
--------------------编程问答--------------------
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>589832</EventID>
<Type>3</Type>
<SubType Name="Warning">0</SubType>
<Level>4</Level>
<TimeCreated SystemTime="2012-12-24T07:58:56.8369460Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="w3wp" ProcessID="3428" ThreadID="8" />
<Channel />
<Computer>BXSERVER</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning">
<TraceIdentifier>http://msdn.microsoft.com/zh-CN/library/System.ServiceModel.Activation.WebHostNoCBTSupport.aspx</TraceIdentifier>
<Description>Extended protection is not supported or not enabled on this platform. Please install the appropriate patch and enable it if you want extendedProtection support for https with windows authentication.</Description>
<AppDomain>/LM/W3SVC/2064611869/Root-3-130008095261362870</AppDomain>
<Source>System.ServiceModel.Activation.MetabaseSettingsIis6/9952002</Source>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
谢谢!!,还是没搞定,这个extension不知道怎么配....T_T
补充:.NET技术 , Web Services