Wcf服务没有获取大量数据(文本) [英] Wcf service not taking huge data(text)

查看:61
本文介绍了Wcf服务没有获取大量数据(文本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有客户端A和客户端B.他们通过WCF服务进行通信。



我正在尝试发送大量文本(15000个字符),但WCF服务不是获取此数据。



但是当我发送8100个字符的文本时,WCF服务获取数据并发送给客户B.



请告诉我如何解决这个问题...



以下是我的Web.config:



 <  配置 >  

< appSettings >
< add key = ASPNET:UseTaskFriendlySynchronizationContext value = true / >
< / appSettings >
< system.web >
< 编译 debug = true targetFramework = 4.5 / >
< httpRuntime targetFramework = 4.5 / >
< / system.web >
< system.serviceModel >
< 行为 >
< serviceBehaviors >
< 行为 >
<! - - 为避免泄露元数据信息,请在部署前将以下值设置为false - >
< serviceMetadata httpGetEnabled = true httpsGetEnabled = true / >
<! - 接收异常详情在错误中出于调试目的,请将以下值设置为true。在部署之前设置为false以避免泄露异常信息 - >
< serviceDebug includeExceptionDetailInFaults = false / >
< / behavior < span class =code-keyword>>

< / serviceBehaviors >
< / behavior >
< 服务 >
< service 名称 = WcfService.Service1 >
< endpoint address = binding = wsDualHttpBinding 合同 = WcfServiceLibrary.IMyService / >
< 端点 地址 = mex binding = mexHttpBinding 合同 = IMetadataExchange / >
< 主机 >
< baseAddresses < span class =code-keyword>>

< add baseAddress = http://localhost/Service1.svc / >
< / baseAddresses >
< / host >
< / service >
< / services >
< protocolMapping >
< add binding = basicHttpsBinding scheme = https / >
< / protocolMapping >
< serviceHostingEnvironment aspNetCompatibilityEnabled = true multipleSiteBindingsEnabled = true / >
< / system.serviceModel >
< system.webServer >
< modules runAllManagedModulesForAllRequests = true / >
<! -
要在调试期间浏览Web应用程序根目录,请将以下值设置为true。
在部署之前设置为false以避免泄露Web应用程序文件夹信息。
- >

< directoryBrowse 已启用 = true / >
< / system.webServer >

< / configuration >









CLient A代码(按钮点击代码,我发送数据)



 DataMessage message =  new  DataMessage(); 
message.Age =& quot;
string Xml = _DataResult;
message.Name = Xml.ToString();





客户B代码(文本框从WCF服务获取结果)

  this  .label1.Text = eventData.Age; 
this .textBox1.Text = eventData.Name;





WCF中的DataMember:

 [DataMember] 
public 字符串名称{获取; set ; }
[DataMember]
public string 年龄{获得; set ; }





我尝试过:



请建议我如何解决这个问题

解决方案

欢迎来到wcf世界....这就是为什么我不再使用它,因为你有这么多当你不知道你会收到什么的大小时,你会惊喜地生产......



看看装订中的选项,

你有maxReceivedMessageSize,maxBufferSize,maxBufferPoolSize,readerQuotas来设置,

这里有一个例子:

  <   basichttpbinding  >  
< binding name = basicHttp allowcookies = true >
maxReceivedMessageSize =10000000
maxBufferSize =10000000
maxBufferPoolSize =10000000
< readerquotas maxdepth = 32 >
maxArrayLength =100000000
maxStringContentLength =100000000
< / readerquotas < span class =code-keyword>> < / binding >
< / basichttpbinding >


At service section使用wsDualHttpBinding将 bindingConfiguration 元素添加到您的终端:

 <   endpoint    地址  =     binding   =  wsDualHttpBinding    bindingconfiguration   =  myBindingConfig    contract   =  WcfServ iceLibrary.IMyService    /  >  



的根目录system.serviceModel 部分添加绑定包含如下配置的部分:

 <  绑定 >  
< wsDualHttpBinding >
< binding name = myBindingConfig maxReceivedMessageSize = 25000 / >
< / wsDualHttpBinding >
< / bindings >


I have Client A and Client B. They communicate through WCF Service.

I am trying to send huge text(15000 characters), but WCF Service is not getting this data.

But when I send 8100 characters of text, WCF Service gets the data, and send to client B.

Please tell me how to solve this issue...

below is my Web.config:

<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name ="WcfService.Service1" >
        <endpoint address ="" binding ="wsDualHttpBinding" contract ="WcfServiceLibrary.IMyService"/>
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress ="http://localhost/Service1.svc"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>





CLient A code(Button click code where I am sending Data)

DataMessage message = new DataMessage();
                message.Age = &quot;
                string Xml = _DataResult;
                message.Name = Xml.ToString();



Client B code(Where textbox gets the result from WCF Service)

this.label1.Text = eventData.Age;
            this.textBox1.Text = eventData.Name;



DataMember in WCF:

[DataMember]
        public string Name { get; set; }
[DataMember]
        public string Age { get; set; }



What I have tried:

Please suggest me how to solve this Issue

解决方案

Welcome in the wcf world.... that's why i don t use it anymore, because you have so much surprise in production when you don t know the size of what you will receive...

look in option in the binding ,
you have maxReceivedMessageSize,maxBufferSize,maxBufferPoolSize,readerQuotas to set,
here is an example :

<basichttpbinding>
    <binding name="basicHttp" allowcookies="true">
             maxReceivedMessageSize="10000000"
             maxBufferSize="10000000"
             maxBufferPoolSize="10000000"
        <readerquotas maxdepth="32">
             maxArrayLength="100000000"
             maxStringContentLength="100000000"
    </readerquotas></binding>
</basichttpbinding>


At service section add bindingConfiguration element to your endpoint with wsDualHttpBinding:

<endpoint address="" binding="wsDualHttpBinding" bindingconfiguration="myBindingConfig" contract="WcfServiceLibrary.IMyService" />


To root of system.serviceModel section add bindings section with configuration like this:

<bindings>
    <wsDualHttpBinding>
        <binding name="myBindingConfig" maxReceivedMessageSize="25000" />
    </wsDualHttpBinding>
</bindings>


这篇关于Wcf服务没有获取大量数据(文本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆