0

我知道很多人已经发布了关于这个的解决方案,我已经尝试了所有发布在互联网上的解决方案,但这些对我不起作用。在这种情况下,我想从 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 配置中指定的内容

4

1 回答 1

2

将行为添加到 congig 并将其添加到服务中

<serviceBehaviors>
      <behavior name="DefaultBehavior" MaxItemsInObjectGraph="2147483647">
         <dataContractSerializer maxItemsInObjectGraph="2147483647" />
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
</serviceBehaviors> 
于 2013-05-31T08:21:39.017 回答