【发布时间】:2011-07-24 11:53:13
【问题描述】:
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" />
服务器上的网络配置
<?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>
【问题讨论】:
-
看看maxItemsInObjectGraph属性,也许这会对你有所帮助
-
我添加了该行为,但不幸的是它仍然带有错误的请求。不过,我会进一步研究行为选项,看看是否还有其他可能性。
-
您确实在服务的
配置部分中配置了 basicHttpBinding 对吗? maxItemsInObjectGraph 和 MaxRecieveivedMessageSize 等一样吗? -
你能发布详细的异常堆栈跟踪吗?在客户端包含异常错误时,您还可以发布您正在调用的方法的签名吗?