我知道很多人已经发布了关于这个的解决方案,我已经尝试了所有在互联网上发布的解决方案,但这些都不适合我。在这个场景中,我想要从一个SharePoint定时器作业中消费WCF服务。
我经常遇到如下问题:
格式化程序在试图反序列化时抛出异常消息:在尝试反序列化参数时出现错误
http://test/MyEntry/2010/03:GetResult
。InnerException消息可以序列化或反序列化的最大项数对象图是65536。更改对象图或增加MaxItemsInObjectGraph配额。"。详情请参见InnerException细节。
我的服务器端web。SVC的配置为:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IVerksamhetService_server" closeTimeout="10:10:00"
openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false" >
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="SomeService.DeluxeEntryBehavior" name="SomeService.DeluxeEntry">
<endpoint address="" binding="wsHttpBinding" contract="SomeService.IVerksamhetService" bindingConfiguration="WSHttpBinding_IVerksamhetService_server" >
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SomeService.DeluxeEntryBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我的客户端配置(我在OWSTIMER.EXE.CONFIG
文件中添加了这个配置)
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IVerksamhetService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceViewEventBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://testserver.ivodmz.za/TestService/MyWCF.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IVerksamhetService"
contract="IVerksamhetService" behaviorConfiguration= "ServiceViewEventBehavior" name="WSHttpBinding_IVerksamhetService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
更新:
我有WCF端点将限制设置为65536,但如何使端点忽略dll行为并使用XML配置中指定的内容?
为congig添加行为并将其添加到服务
<serviceBehaviors>
<behavior name="DefaultBehavior" MaxItemsInObjectGraph="2147483647">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>