【发布时间】:2009-12-19 10:49:33
【问题描述】:
所有更改 WCF 自托管服务端点配置设置的尝试均失败:
public void Start()
{
BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "NAVBinding";
//--------------------START editing-------------------------------
TimeSpan interval = new TimeSpan(1, 50, 00); // all these following (inbetween comments) lines have no effect
binding.MaxReceivedMessageSize = 2147483647;
binding.MaxBufferSize = 2147483647;
binding.ReceiveTimeout = interval;
binding.OpenTimeout = interval;
binding.CloseTimeout = interval;
binding.SendTimeout = interval;
XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
readerQuotas.MaxDepth = 2147483647;
readerQuotas.MaxStringContentLength = 2147483647;
readerQuotas.MaxArrayLength = 2147483647;
readerQuotas.MaxBytesPerRead = 2147483647;
readerQuotas.MaxNameTableCharCount = 2147483647;
binding.ReaderQuotas = readerQuotas;
//----------------------END editing---------------------------
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
Uri baseAddress = new Uri("http://localhost:8000/nav/customer");
Customer_Service service = new Customer_Service();
serviceHost = new ServiceHost(service, baseAddress);
serviceHost.AddServiceEndpoint(typeof(ICustomer_Service), binding, baseAddress);
OpenMetadataExchange(baseAddress);
service.navEventListner = this;
serviceHost.Open();
}
但我可以在 wcfStorm 应用程序的帮助下轻松更改 MaxReceivedMessageSize 属性,在这种情况下,它确实被更改了。但重启服务后,一切都恢复到默认设置(例如 MaxReceivedMessageSize = 65536)。
拜托,我做错了什么?如何编辑我的代码以更新新值?
【问题讨论】:
-
您如何知道这些设置不起作用?您是否希望更新配置文件,或者您的期望是什么?
-
我知道设置无法通过尝试调用应该传输大于 65536 的数据的方法,在这种情况下我有一个错误(另一种传输较少数据的方法可以完成) .如果我使用 wcf 测试应用程序(在我的情况下为 wcfstorm),将两个参数 MaxReceivedMessageSize 和 MaxBufferSize 更改为更大的值,则具有大数据的该方法调用并完成没有问题。
-
我也尝试了很多使用 app.config 文件(基于客户端和服务器)但没有任何帮助。我没有在我的问题中强调这一点,因为我认为那些 C# 硬编码设置有更大的影响(也许我错了,但事实上,起初在服务器端服务应用程序中我没有 app.config文件中的任何一个都运行良好(除了那些新的 MessageSize 绑定参数)。
标签: wcf web-services binding endpoints