我在上传更大尺寸的文件时遇到问题。我正在将 WCF 服务的 basicHttpBinding 用于请求/响应,它的形成方式如下,
int MAXSIZE = Int32.MaxValue;
BasicHttpBinding binding = new BasicHttpBinding()
{
CloseTimeout = new TimeSpan(0, 1, 0),
OpenTimeout = new TimeSpan(0, 1, 0),
ReceiveTimeout = new TimeSpan(0, 10, 0),
SendTimeout = new TimeSpan(0, 10, 0),
AllowCookies = false,
BypassProxyOnLocal = false,
HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
MaxBufferSize = MAXSIZE,
MaxBufferPoolSize = MAXSIZE,
MaxReceivedMessageSize = MAXSIZE,
MessageEncoding = WSMessageEncoding.Text,
TextEncoding = System.Text.Encoding.UTF8,
TransferMode = System.ServiceModel.TransferMode.Buffered,
UseDefaultWebProxy = true,
};
binding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
{
MaxDepth = 32,
MaxStringContentLength = MAXSIZE,
MaxArrayLength = MAXSIZE,
MaxBytesPerRead = MAXSIZE,
MaxNameTableCharCount =16384,
};
根据网上的答案,它应该可以工作,但是它会引发异常。远程服务器返回意外响应:(400) 错误请求。
有没有人遇到过这种情况?