问题描述
最近调用wcf互操作时服务端提示如下信息:Themaximummessagesizequotaforincomingmessages(65536)hasbeenexceeded.Toincreasethequota,usetheMaxReceivedMessageSizepropertyontheappropriatebindingelement.应该是说序列化后传输的数据量大于65536,要设置MaxReceivedMessageSize扩大可传输的数据量,但是这个属性我在客户端服务端都配置过了,具体如下WCF服务端配置在IIS6中,win2k3sp2系统,配置如下:<bindings><basicHttpBinding><bindingname='basicHttpBindingConfig'maxBufferSize='2147483647'maxBufferPoolSize='2147483647'maxReceivedMessageSize='2147483647'messageEncoding='Mtom'transferMode='Streamed'><readerQuotasmaxDepth='2147483647'maxStringContentLength='2147483647'maxArrayLength='2147483647'maxBytesPerRead='2147483647'maxNameTableCharCount='2147483647'/></binding></basicHttpBinding></bindings>
在客户端是用代码进行配置的,如下:m_BasicHttpBindingConfig=newBasicHttpBinding{Name="basicHttpBindingConfig",MaxBufferSize=2147483647,MaxBufferPoolSize=2147483647,MaxReceivedMessageSize=2147483647,//MessageEncoding=WSMessageEncoding.Mtom,TransferMode=TransferMode.Streamed,ReaderQuotas=newSystem.Xml.XmlDictionaryReaderQuotas{MaxDepth=2147483647,MaxStringContentLength=2147483647,MaxArrayLength=2147483647,MaxBytesPerRead=2147483647,MaxNameTableCharCount=2147483647},Security=newBasicHttpSecurity{Mode=BasicHttpSecurityMode.None,Transport=newHttpTransportSecurity{ClientCredentialType=HttpClientCredentialType.None,ProxyCredentialType=HttpProxyCredentialType.None,Realm=""},Message=newBasicHttpMessageSecurity{ClientCredentialType=BasicHttpMessageCredentialType.UserName,AlgorithmSuite=SecurityAlgorithmSuite.Default}},SendTimeout=newTimeSpan(0,30,0)};
两个问题:1)其中的maxReceivedMessageSize都是配置过的,但是调用时数据量增大时还是会报超65536的错,难道是IIS或OS的问题么?2)另外,还有一个问题是,明明服务端已经配置过messageEncoding='Mtom',客户端代码配置//MessageEncoding=WSMessageEncoding.Mtom编译是没错,但是运行是根本无法和wcf服务端进行交互的,这个太奇怪了,不得解啊
解决方案
解决方案二:
又看了一下tracelog,上面在报maxReceivedMessageSize之前,还有一个警告:<E2ETraceEventxmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><Systemxmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>524312</EventID><Type>3</Type><SubTypeName="Warning">0</SubType><Level>4</Level><TimeCreatedSystemTime="2012-12-24T06:33:07.5293604Z"/><SourceName="System.ServiceModel"/><CorrelationActivityID="{21907a84-e748-4e8e-8b91-92d21c9e25cc}"/><ExecutionProcessName="w3wp"ProcessID="2828"ThreadID="6"/><Channel/><Computer>BXSERVER</Computer></System><ApplicationData><TraceData><DataItem><TraceRecordxmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"Severity="Warning"><TraceIdentifier>http://msdn.microsoft.com/zh-CN/library/System.ServiceModel.EvaluationContextNotFound.aspx</TraceIdentifier><Description>Configurationevaluationcontextnotfound.</Description><AppDomain>/LM/W3SVC/803627/Root/EPS.Business.WCF-3-130008043855298980</AppDomain></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent>
说没找到配置评估上下文,这样是不是我写的配置就一直没起作用啊?配置应该不会有问题吧?配置如下:<?xmlversion='1.0'encoding='utf-8'?><configuration><configSections><sectionGroupname='applicationSettings'type='System.Configuration.ApplicationSettingsGroup,System,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089'><sectionname='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><sourcename='System.ServiceModel.MessageLogging'switchValue='Warning,ActivityTracing'><listeners><addtype='System.Diagnostics.DefaultTraceListener'name='Default'><filtertype=''/></add><addname='ServiceModelMessageLoggingListener'><filtertype=''/></add></listeners></source><sourcename='System.ServiceModel'switchValue='Warning,ActivityTracing'propagateActivity='true'><listeners><addtype='System.Diagnostics.DefaultTraceListener'name='Default'><filtertype=''/></add><addname='ServiceModelTraceListener'><filtertype=''/></add></listeners></source></sources><sharedListeners><addinitializeData='C:app_messages.svclog'type='System.Diagnostics.XmlWriterTraceListener,System,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089'name='ServiceModelMessageLoggingListener'traceOutputOptions='Timestamp'><filtertype=''/></add><addinitializeData='C:app_tracelog.svclog'type='System.Diagnostics.XmlWriterTraceListener,System,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089'name='ServiceModelTraceListener'traceOutputOptions='Timestamp'><filtertype=''/></add></sharedListeners><traceautoflush='true'/></system.diagnostics><system.web><compilationdebug='true'/><httpRuntimemaxRequestLength='2097151'/></system.web><!--部署服务库项目时,必须将配置文件的内容添加到主机的app.config文件中。System.Configuration不支持库的配置文件。--><system.serviceModel><diagnostics><messageLogginglogMalformedMessages='true'logMessagesAtTransportLevel='true'/></diagnostics><bindings><basicHttpBinding><bindingname='basicHttpBindingConfig'maxBufferSize='2147483647'maxBufferPoolSize='2147483647'maxReceivedMessageSize='2147483647'messageEncoding='Mtom'transferMode='Streamed'><readerQuotasmaxDepth='2147483647'maxStringContentLength='2147483647'maxArrayLength='2147483647'maxBytesPerRead='2147483647'maxNameTableCharCount='2147483647'/></binding></basicHttpBinding></bindings><services><!--BusinessDepartmentService--><servicename='EPS.EntityCollection.Business.BusinessDepartmentService'><endpointaddress=''binding='basicHttpBinding'bindingConfiguration='basicHttpBindingConfig'name='BusinessDepartmentService'contract='EPS.EntityCollection.Business.IBusinessDepartmentService'></endpoint><endpointaddress='mex'binding='mexHttpBinding'contract='IMetadataExchange'/><host><baseAddresses><addbaseAddress='http://192.168.1.1/TTS.WCF/BusinessDepartmentService.svc'/></baseAddresses></host></service><!--BusinessPostService--><servicename='EPS.EntityCollection.Business.BusinessPostService'><endpointaddress=''binding='basicHttpBinding'bindingConfiguration='basicHttpBindingConfig'name='BusinessPostService'contract='EPS.EntityCollection.Business.IBusinessPostService'></endpoint><endpointaddress='mex'binding='mexHttpBinding'contract='IMetadataExchange'/><host><baseAddresses><addbaseAddress='http://192.168.1.1/TTS.WCF/BusinessPostService.svc'/></baseAddresses></host></service></services><behaviors><serviceBehaviors><behavior><!--为避免泄漏元数据信息,请在部署前将以下值设置为false并删除上面的元数据终结点--><serviceMetadatahttpGetEnabled='True'/><!--要接收故障异常详细信息以进行调试,请将以下值设置为true。在部署前设置为false以避免泄漏异常信息--><serviceDebugincludeExceptionDetailInFaults='true'/></behavior></serviceBehaviors></behaviors></system.serviceModel></configuration>
解决方案三:
解决方案四:
第一个问题你搞定了?第二个问题:参考这个http://stackoverflow.com/questions/3636341/configuration-evaluation-context-not-found-warning-on-wcf-traceTheevaluationcontextnotfounderror(orintraceswiththeidentifierSystem.ServiceModel.EvaluationContextNotFound)isgenerallycausedbyusingaconfigurationelementdefinedinalibrarythatisnotincludedintheapplication’sconfigurationasanextension.
解决方案五:
引用2楼fangxinggood的回复:
http://blog.csdn.net/fangxinggood/article/details/6031072
还是不行,报一样的错.我再部署了一下,测试后发现在tracelog最开头有一个警告:<E2ETraceEventxmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><Systemxmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>589832</EventID><Type>3</Type><SubTypeName="Warning">0</SubType><Level>4</Level><TimeCreatedSystemTime="2012-12-24T07:58:56.8369460Z"/><SourceName="System.ServiceModel"/><CorrelationActivityID="{00000000-0000-0000-0000-000000000000}"/><ExecutionProcessName="w3wp"ProcessID="3428"ThreadID="8"/><Channel/><Computer>BXSERVER</Computer></System><ApplicationData><TraceData><DataItem><TraceRecordxmlns="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>Extendedprotectionisnotsupportedornotenabledonthisplatform.PleaseinstalltheappropriatepatchandenableitifyouwantextendedProtectionsupportforhttpswithwindowsauthentication.</Description><AppDomain>/LM/W3SVC/2064611869/Root-3-130008095261362870</AppDomain><Source>System.ServiceModel.Activation.MetabaseSettingsIis6/9952002</Source></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent>
解决方案六:
引用3楼book_frank_xl的回复:
第一个问题你搞定了?第二个问题:参考这个http://stackoverflow.com/questions/3636341/configuration-evaluation-context-not-found-warning-on-wcf-traceTheevaluationcontextnotfounderror(orintraces……
谢谢!!,还是没搞定,这个extension不知道怎么配....T_T
解决方案七:
<bindings><basicHttpBinding><bindingname='basicHttpBindingConfig'maxBufferSize='2147483647'maxBufferPoolSize='2147483647'maxReceivedMessageSize='2147483647'messageEncoding='Mtom'transferMode='Streamed'><readerQuotasmaxDepth='2147483647'maxStringContentLength='2147483647'maxArrayLength='2147483647'maxBytesPerRead='2147483647'maxNameTableCharCount='2147483647'/></binding></basicHttpBinding></bindings>这玩意应该写在客户端