如何以编程方式设置 WCF 客户端 maxBufferSize 参数?
我以编程方式设置 wcf 客户端参数,如下所示:
try
{
ServiceReference1.MyDbServiceClient webService =
new ServiceReference1.MyDbServiceClient(new System.ServiceModel.BasicHttpBinding(),
new System.ServiceModel.EndpointAddress((string)((App)Application.Current).Resources["wcfMyDBServiceEndPoint"]));
webService.GetSeriesImagesCompleted += new EventHandler<ServiceReference1.GetSeriesImagesCompletedEventArgs>(webService_GetSeriesImagesCompleted);
webService.GetSeriesImagesAsync(index);
}
对于默认的 maxBufferSize,它工作得很好。但是,当客户端超过默认大小时,会出现异常:“已超出传入消息的最大消息大小配额 (65536)”。
如何在代码中设置这个参数? 谢谢。
I am setting wcf client parameters programmatically like below:
try
{
ServiceReference1.MyDbServiceClient webService =
new ServiceReference1.MyDbServiceClient(new System.ServiceModel.BasicHttpBinding(),
new System.ServiceModel.EndpointAddress((string)((App)Application.Current).Resources["wcfMyDBServiceEndPoint"]));
webService.GetSeriesImagesCompleted += new EventHandler<ServiceReference1.GetSeriesImagesCompletedEventArgs>(webService_GetSeriesImagesCompleted);
webService.GetSeriesImagesAsync(index);
}
It works just fine for the default maxBufferSize. However when a client exceeds the default size, an exception is throughn: "the maximum message size quota for incoming messages (65536) has been exceeded."
How to set this parameter in code?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的要求创建绑定。
Create binding based on your requirement.