问题描述
|
edit3:我从服务器添加了webconfig
edit2:我运行了日志,这是出现的错误消息:
超出了传入消息的最大消息大小配额(65536)。要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。
由于它仅对2000条记录进行测试,而对200条记录不进行测试,因此我决定更改应用程序设置,前提是它超过了标准限制65535。此问题的两种其他来源,一种是服务本身的设置,另一种是端点中的设置。
提供服务的开发人员说他的一面还可以,而问题只是我曾经做过但不记得的那一面。
我已经将应用程序配置数据添加到了端点,人们说过,如果端点不匹配,将使用默认设置(因此使用65K限制)创建一个默认端点。如果这是问题,我该如何解决?
如果您需要任何其他代码或信息,请告诉我。
编辑:我按照建议将更改添加到应用程序配置
<behaviors>
<endpointBehaviors>
<behavior name=\"MetadataBehavior\">
<dataContractSerializer maxItemsInObjectGraph=\"2147483647\"/>
</behavior>
</endpointBehaviors>
</behaviors>
<binding name=\"BasicHttpBinding_IMailSortService\" closeTimeout=\"00:01:00\"
openTimeout=\"00:01:00\" receiveTimeout=\"00:10:00\" sendTimeout=\"00:01:00\"
allowCookies=\"false\" bypassProxyOnLocal=\"false\" hostNameComparisonMode=\"StrongWildcard\"
maxBufferSize=\"2147483647\" maxBufferPoolSize=\"524288\" maxReceivedMessageSize=\"2147483647\"
messageEncoding=\"Text\" textEncoding=\"utf-8\" transferMode=\"Buffered\"
useDefaultWebProxy=\"true\">
<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>
<endpoint behaviorConfiguration=\"MetadataBehavior\" address=\"http://remote-access/MailSort/MailSortService.svc\"
binding=\"basicHttpBinding\" bindingConfiguration=\"BasicHttpBinding_IMailSortService\"
contract=\"MailSortServiceReference.IMailSortService\" name=\"BasicHttpBinding_IMailSortService\" />
服务器上的webconfig
<?xml version=\"1.0\"?>
<configuration>
<appSettings>
<add key=\"FilePath\" value=\"\\\\162.27.51.43\\DOWNLOAD\\RPA\\Mailsort\\Auto\" />
</appSettings>
<system.web>
<compilation debug=\"true\" targetFramework=\"4.0\" />
<httpRuntime maxRequestLength=\"2147483647\" />
</system.web>
<system.diagnostics>
<sources>
<source name=\"System.ServiceModel\"
switchValue=\"Information,ActivityTracing\"
propagateActivity=\"true\">
<listeners>
<add name=\"traceListener\"
type=\"System.Diagnostics.XmlWriterTraceListener\"
initializeData= \"c:\\logs\\Traces.svclog\" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<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=\"true\"/>
<dataContractSerializer maxItemsInObjectGraph=\"2147483647\"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled=\"true\" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests=\"true\"/>
</system.webServer>
</configuration>
解决方法
评论太大了,变成一个答案:
您是否将行为指向终点?
<endpoint address=\"http:blah/MyService.svc\" behaviorConfiguration=\"MyServiceBehavior\".
当前的配置适用于200,但不适用于2000?如果是这样,您是否可以尝试将服务绑定修改为如下所示的最大值,看看是否有帮助(您也会在服务端反映相同的属性)?
<readerQuotas maxDepth=\"2147483647\" maxStringContentLength=\"2147483647\" maxArrayLength=\"2147483647\" maxBytesPerRead=\"2147483647\" maxNameTableCharCount=\"2147483647\"/>
,我没有看到对此信息启用评论。
我没有发表评论,而是给出了答案。
根据下面的帖子,请确保您为服务合同使用了完全限定的名称空间。
http://forums.silverlight.net/forums/p/191589/442378.aspx
<endpoint behaviorConfiguration=\"MetadataBehavior\" address=\"http://remote-access/MailSort/MailSortService.svc\"
binding=\"basicHttpBinding\" bindingConfiguration=\"BasicHttpBinding_IMailSortService\"
contract=\"FullyQualifiedNamespace.IMailSortService\" name=\"BasicHttpBinding_IMailSortService\" />
,解决方案是下面的应用程序配置设置。
通过WCF发送大消息时,需要将以下代码添加到服务器上的web.config和本地应用程序上的app.config中。然后,这将使服务器和本地配置使用用户定义的消息大小。
包括在部分中。
<protocolMapping>
<remove scheme=\"http\" />
<add scheme=\"http\" binding=\"basicHttpBinding\" bindingConfiguration=\"BasicHttpBinding_IMailSortService\" />
</protocolMapping>