在WCF中传输10-40MB的数据

时间:2011-02-24 22:05:21

标签: wcf

我正在使用Message安全性和Windows凭据类型。我现在没有出于某种原因使用流媒体和Mtom,但未来可能会考虑。到目前为止,WCF服务文档指定您可以传输最多2GB的数据。我在想是否可以根据WCF规范传输20-40 MB的数据,这对我现在有用,尽管现在这样做很糟糕。

我可以从WCF服务向客户端传输最多10MB的数据,但是当我尝试增加超过10MB的数据时,阻止它将数据从服务器传输到客户端,我不知道是什么。
我正在将对象集合从Web Service转移到Client。 当数据没有从服务器传输到客户端时,我没有收到任何错误消息,这很奇怪。当我在客户端和服务器绑定属性中将传输大小设置为10MB以下时,我可以转移1650个对象的集合,但是当它在1900年左右时,我在客户端上没有得到任何东西????为什么????

为了使它工作我将所有require属性设置为max并且它仍然无效。 以下是我在客户端的内容:

<ws2007HttpBinding>
      <binding name="CustomizeWs2007HttpBinding" sendTimeout="00:10:00" closeTimeout="00:10:00"
          openTimeout="00:10:00" messageEncoding="Text" receiveTimeout="00:10:00"
          maxBufferPoolSize="0"
          maxReceivedMessageSize="2147483647"
          >
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
                         maxBytesPerRead="4096" />
          <security mode="Message">
             <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true"/>
          </security>
      </binding></ws2007HttpBinding>

以下是我在WCF服务(服务器)中的内容:

<ws2007HttpBinding>
      <binding name="KerberosBinding" maxBufferPoolSize="0" maxReceivedMessageSize="2147483647"
               messageEncoding="Text" sendTimeout="00:10:00" closeTimeout="00:10:00"
          openTimeout="00:10:00">
        <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
                         maxBytesPerRead="4096" />
        <security>
          <message negotiateServiceCredential="true" establishSecurityContext="true"/>
        </security>
      </binding></ws2007HttpBinding>

我希望有人有答案。 非常感谢你。

谢谢Chris,它现在正在工作,感谢所有其他人的回复。 我是这个网站的新成员,所以不知道在哪里提出我的最终解决方案,无论如何它粘贴在下面:

15728640 = 15MB
10485760 = 10MB虽然太大了

客户端配置:

<behaviors>
  <endpointBehaviors>
    <behavior name="PServiceBehavior">
      <dataContractSerializer maxItemsInObjectGraph="10485760"/>
    </behavior>
  </endpointBehaviors>
</behaviors>

并从端点引用它:

<endpoint address="http://localhost:53054/pservicehost/pservice.svc"

binding =“ws2007HttpBinding”bindingConfiguration =“PServiceWs2007HttpBinding”behaviorConfiguration =“PServiceBehavior” contract =“PWebServiceContract.IPService”name =“PServiceWs2007HttpBindingEndPoint”&gt;   

服务配置:

<behaviors>
  <serviceBehaviors>
    <behavior name="PServiceHost.PServiceBehavior">
   <serviceMetadata httpGetEnabled="true" />
   <serviceDebug includeExceptionDetailInFaults="true" />
   <dataContractSerializer maxItemsInObjectGraph="10485760"/>
    </behavior>
  </serviceBehaviors>
 </behaviors>

并从服务中引用它:

<services>
   <service behaviorConfiguration="PServiceHost.PServiceBehavior"  name="PWebService.PService">
  <endpoint address="" binding="ws2007HttpBinding" bindingConfiguration="KerberosBinding" contract="PWebServiceContract.IPService">
  <identity>
      <dns value="localhost" />
  </identity>
  </endpoint>
  <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
   </services>

2 个答案:

答案 0 :(得分:2)

可能与此油门设置有关:

<dataContractSerializer maxItemsInObjectGraph="..."/>

答案 1 :(得分:1)

我建议您在服务器上启用WCF跟踪。这是一个非常有用的工具。它在过去帮助了我很多,特别是如果在服务器端存在一些您无法在其他任何地方轻易检测到的异常情况。

以下链接说明了如何启用它:Service Trace Viewer Tool (SvcTraceViewer.exe)