WCF 通讯 数据多了出错
service :[DataContract]
class Contact
{
string m_FirstName;
IPAddress m_LastName;
[DataMember]
public string FirstName
{
get
{
return m_FirstName;
}
set
{
m_FirstName = value;
}
}
[DataMember]
public IPAddress LastName
{
get
{
return m_LastName;
}
set
{
m_LastName = value;
}
}
}
[ServiceContract]
inte易做图ce IContactManager
{
[OperationContract]
void AddContact(List<Contact> contact);
[OperationContract]
Dictionary<int,List<Contact>> GetContacts();
}
class ContactManager : IContactManager
{
Dictionary<int,List<Contact>> m_Contacts = new Dictionary<int,List<Contact>> ();
public void AddContact(List<Contact> contact)
{
for (int i = 0; i < 2000; i++)
{
m_Contacts.Add(i,contact);
}
}
public Dictionary<int, List<Contact>> GetContacts()
{
return m_Contacts;
}
}
client:
Contact contact = new Contact();
contact.FirstName = "Juval";
contact.LastName = IPAddress.Parse( "192.168.12.1");
List<Contact> contactList = new List<Contact>();
contactList.Add(contact);
ContactManagerClient proxy = new ContactManagerClient();
proxy.AddContact(contactList);
Dictionary<int, List<Contact>> colelction = proxy.GetContacts();
proxy.Close();
config:
<system.serviceModel>
<services>
<service name = "ContactManager">
<endpoint
address = "http://localhost:8000/ContactManager"
binding = "wsHttpBinding" bindingConfiguration="NewBindingStationCnfg"
contract = "IContactManager">
</endpoint>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="NewBindingStationCnfg" maxReceivedMessageSize="2147483647" />
</wsHttpBinding>
</bindings>
</system.serviceModel>
for (int i = 0; i < 2000; i++)
{
m_Contacts.Add(i,contact);
}
i=2000 的时候没问题,当把它改为5000的时候出错,出错信息 "基础连接已经关闭: 接收时发生错误
接收对 http://localhost:8000/ContactManager/ 的 HTTP 响应时发生错误。这可能是由于服务终结点绑定未使用 HTTP 协议造成的。这还可能是由于服务器中止了 HTTP 请求上下文(可能由于服务关闭)所致。有关详细信息,请参阅服务器日志
--------------------编程问答-------------------- <binding name="TcpSession" openTimeout="00:30:00" sendTimeout="00:30:00" maxReceivedMessageSize="655360">
...
试试在Server和Client中这样配置binding... --------------------编程问答-------------------- 感谢您的回复,我已经加了配置了,不过还是无效? --------------------编程问答-------------------- 把那些buf之类的值改大一些! --------------------编程问答-------------------- 都改成最大了,还是一样! --------------------编程问答-------------------- OperationContract默认是双向的,你的代码生成了那么多数据,最后都要返回给client。
建议用IsOneWay = true,然后用别的方法得到生成的数据。
最后再次BS微软:BUG太多了!!!!!!!而且不让我们反馈,有BUG只有暨希望与他老人家”主动“修改。 --------------------编程问答-------------------- 没有人“报告BUG”的软件,是那些没有人愿意看一眼的软件。 --------------------编程问答-------------------- 对传输数据大小有限制是很正常的,和IsOneWay没什么关系。
建议你分页传或者用Stream传。 --------------------编程问答-------------------- 5000个就不行了,webservice也不止这么多啊 --------------------编程问答-------------------- 关注................. --------------------编程问答-------------------- 有可能是数据变大了
客户端的 配置文件也要改, 这个不会自动生成,有时候挺郁闷的 (我指的是那个大小, 客户端会用默认值)
另外,建议先打开<serviceDebug includeExceptionDetailInFaults="true" /> 看看异常,或者开启日志也可以~
--------------------编程问答-------------------- 客户端配置改了,debug也打开了,错误信息就是我开始贴的那个 --------------------编程问答-------------------- --------------------编程问答-------------------- 还没解决 --------------------编程问答-------------------- 是不是IIS那边超时了,你看看IIS的配置 --------------------编程问答-------------------- 没用到iis,host在winform中 --------------------编程问答-------------------- 网络传输时数据建议不要使用Dictionary,你可以看看Dictionary 的内部实现,它要比普通集合花费一倍多的存储。对于大数据量集合,建议单条传输 --------------------编程问答-------------------- 什么叫单条传输? --------------------编程问答-------------------- 建议使用NetTcpBinding,呵呵 --------------------编程问答--------------------
都一样! --------------------编程问答-------------------- 我也碰到了.
不知道LZ解决没?
如解决了,恢复一下.
我也正在找答案 --------------------编程问答-------------------- 没解决呢 --------------------编程问答-------------------- 是不是在做class Contact 数据模板时,找一下好像是INotification这个方法,把默认Two Way Mode设置改成OneWay的只读 --------------------编程问答-------------------- silverlight里的datagrid最多可以承受几万条数据,如果用wcf和webservice可能没这么多,但两者承载数据量的上限基本是一样的,承载数据量的大小取决于数据模板的复杂度 --------------------编程问答--------------------
告诉我邮箱,我把demo发给你! --------------------编程问答-------------------- http://topic.csdn.net/u/20080708/08/8158eac6-08fd-4e04-b37d-7dfc8137a6d9.html --------------------编程问答-------------------- 服务器端
<basicHttpBinding>
<binding name="DefaultBindingConfig" closeTimeout="00:05:00" maxBufferSize="1073741824" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824" openTimeout="00:05:00" sendTimeout="00:05:00"/>
</basicHttpBinding>
客户端
--------------------编程问答-------------------- 默认好像是65536,我现在已经改成了10M...
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DefaultBindingConfig" maxBufferSize="1073741824"
maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824"
sendTimeout="00:05:00" closeTimeout="00:05:00" openTimeout="00:05:00">
</binding>
</basicHttpBinding>
</bindings>
我遇到与你类似的问题
现在OK了,不过一次超过10M也没必要,可以分多次传送...
--------------------编程问答-------------------- 1 可将时间相应设置长一些
2 可将传输数据切成小片(如1K)多次传输 --------------------编程问答-------------------- 我也碰到相应的问题, 可以启用流处理 TransMode = "Streamed" --------------------编程问答-------------------- 我的,
服务端:
<bindings>
<netTcpBinding>
<binding name="NewBinding0" maxReceivedMessageSize="1073741824" maxBufferSize="1073741824">
<readerQuotas maxStringContentLength="1073741824" maxBytesPerRead="1073741824" maxArrayLength="1073741824" />
</binding>
</netTcpBinding>
<basicHttpBinding>
<binding name="DocumentExplorerServiceBinding" maxReceivedMessageSize="1073741824" maxBufferSize="1073741824" maxBufferPoolSize="1073741824" sendTimeout="00:10:00" transferMode="StreamedRequest" messageEncoding="Text" textEncoding="utf-8">
<readerQuotas maxStringContentLength="1073741824" maxBytesPerRead="1073741824" maxArrayLength="1073741824" maxDepth="1073741824" maxNameTableCharCount="1073741824" />
<security mode="None"/>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webHttp0" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824" maxBufferSize="1073741824" transferMode="Streamed" writeEncoding="utf-8">
<readerQuotas maxStringContentLength="1073741824" maxBytesPerRead="1073741824" maxArrayLength="1073741824" maxDepth="64" maxNameTableCharCount="1073741824" />
<security mode="None"/>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="wsHttp01" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824">
<readerQuotas maxBytesPerRead="1073741824" maxArrayLength="1073741824" maxStringContentLength="1073741824" maxDepth="64" maxNameTableCharCount="1073741824"/>
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
客户端:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PsslWsSoap" maxBufferSize="1073741824" maxReceivedMessageSize="1073741824">
<security mode="None" />
</binding>
<binding name="BasicHttpBinding_PsService" maxBufferSize="1073741824"
maxReceivedMessageSize="1073741824">
<security mode="None" />
</binding>
<binding name="BasicHttpBinding_PsslWcf" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
<binding name="BasicHttpBinding_PsslWcfDb" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
都还不行,还是超过64K就报错:NotFound. 这东西真是折磨人。 --------------------编程问答-------------------- 支持29楼!绝对是流操作! --------------------编程问答-------------------- up
补充:.NET技术 , .NET Framework