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]
interface 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 请求上下文(可能由于服务关闭)所致
整个解决方案可以告诉我邮箱,我发给您!