WCF:InnerException消息是'可以的最大项目数>对象图中的序列化或反序列化是'65536'

时间:2013-05-31 05:55:50

标签: wcf sharepoint-2010 config wcf-binding timer-jobs

我知道很多人已经发布了有关此问题的解决方案,我已经尝试了所有在互联网上发布的解决方案,但那些对我不起作用。在这种情况下,我想从SharePoint计时器作业中使用WCF服务。

我经常遇到以下问题:

  

格式化程序在尝试反序列化时抛出异常   消息:尝试反序列化参数时出错   http://test/MyEntry/2010/03:GetResult。 InnerException消息   '可以序列化或反序列化的最大项目数   对象图是'65536'。更改对象图或增加   MaxItemsInObjectGraph配额。 ”。有关更多信息,请参阅InnerException   的信息。

SVC的我的服务器端web.config是:

<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配置中指定的内容

1 个答案:

答案 0 :(得分:2)

为配置添加行为并将其添加到服务

<serviceBehaviors>
      <behavior name="DefaultBehavior" MaxItemsInObjectGraph="2147483647">
         <dataContractSerializer maxItemsInObjectGraph="2147483647" />
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
</serviceBehaviors>