将大量对象发送到WCF服务

时间:2015-01-05 23:04:18

标签: wcf

我的客户端WPF应用程序,它读取一个大的CSV文件并根据数据创建对象列表。记录几乎是40,000,因此对象列表是40,000。现在,虽然我更改了web.config和app.config文件的绑定属性,但我尝试发送这些集合但无法发送到Wcf服务。我试图调试wcf代码但没有任何反应,即没有异常或控件没有移动到调试点。例如:

<binding name="BasicHttpBinding_IRulesEngineManagementService"
              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" />

我在谷歌搜索但没有找到解决方案。我完全陷入困境。我该如何解决这个问题?任何类型的提示/想法/代码示例都是可观的。

1 个答案:

答案 0 :(得分:0)

请发布完整的web.config。

设置绑定配置的典型错误是您不会将其设置为服务元素 with bindingConfiguration属性。 你必须有这样的东西

<service ... >
<endpoint ....  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRulesEngineManagementService" .... >

</service>

如果在WCF / IIS端执行代码之前没有遇到任何异常甚至命中断点,这意味着您的服务失败

请将这些配置设置为您的web.config,以便您可以看到此方面的错误。

在你的system.serviceModel部分

<system.serviceModel>
...
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" />
    </diagnostics>     
....
  </system.serviceModel>

并添加新元素system.diagnostics。它会将您的日志保存到c:\ temp \ WCFLoging.svclog。

<system.diagnostics>
    <switches>
      <add name="XmlSerialization.Compilation" value="4"/>
  </switches>
   <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\WCFLoging.svclog" />
    </sharedListeners>
  </system.diagnostics>