- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
关于这个问题有很多讨论,但是我现在已经尝试了所有可能的解决方案,但我们仍然从服务器收到 413 Request Entity Too Large 错误。
我们的 WCF 服务是通过 Azure Worker 角色自行托管的,并且不使用 IIS。我们所有的配置都在代码中指定:
var host = new ServiceHost(searchEngine);
// Create binding
var binding = new WebHttpBinding(WebHttpSecurityMode.Transport);
binding.MaxReceivedMessageSize = 2147483647;
binding.MaxBufferSize = 2147483647;
binding.MaxBufferPoolSize = 2147483647;
var readerQuotas = new XmlDictionaryReaderQuotas
{
MaxStringContentLength = 2147483647,
MaxArrayLength = 2147483647,
MaxBytesPerRead = 2147483647,
MaxDepth = 2147483647,
MaxNameTableCharCount = 2147483647
};
// Setting quotas on a BindingElement after the binding is created has no effect on that binding.
// See: https://stackoverflow.com/questions/969479/modify-endpoint-readerquotas-programatically
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, readerQuotas, null);
binding.ReceiveTimeout = new TimeSpan(1, 0, 0);
binding.SendTimeout = new TimeSpan(1, 0, 0);
// Add the service endpoint
var ep = host.AddServiceEndpoint(
typeof(ISearchEngine),
binding,
string.Format("https://{0}/SearchEngine", externalEndpoint));
ep.Behaviors.Add(new WebHttpBehavior());
// Increase the MaxItemsInObjectGraph quota for all operations in this service
foreach (var operation in ep.Contract.Operations)
{
operation.Behaviors.Find<DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = 10000000;
}
return host;
这是我们的客户端配置 - 也在代码中指定:
var binding = new WebHttpBinding(WebHttpSecurityMode.Transport);
binding.MaxReceivedMessageSize = 2147483647;
binding.MaxBufferSize = 2147483647;
binding.MaxBufferPoolSize = 2147483647;
var readerQuotas = new XmlDictionaryReaderQuotas
{
MaxStringContentLength = 2147483647,
MaxArrayLength = 2147483647,
MaxBytesPerRead = 2147483647,
MaxDepth = 2147483647,
MaxNameTableCharCount = 2147483647
};
// Setting quotas on a BindingElement after the binding is created has no effect on that binding.
// See: https://stackoverflow.com/questions/969479/modify-endpoint-readerquotas-programatically
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, readerQuotas, null);
binding.ReceiveTimeout = new TimeSpan(1, 0, 0);
binding.SendTimeout = new TimeSpan(1, 0, 0);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var channelFactory = new ChannelFactory<ISearchEngine>(binding, endpointAddress);
channelFactory.Endpoint.Behaviors.Add(new WebHttpBehavior());
// Increase the MaxItemsInObjectGraph quota for all operations in this service
foreach (var operation in channelFactory.Endpoint.Contract.Operations)
{
operation.Behaviors.Find<DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = 10000000;
}
return channelFactory.CreateChannel();
我唯一的预感可能是 SSL 连接有问题?有一些文章提到了 IIS 特有的问题,但我不确定这是否与自托管服务相关。
非常感谢任何建议。
为了证实我的预感,SSL 是问题所在,我暂时禁用了 SSL,结果发现问题消失了。
所以现在我需要弄清楚为什么 SSL 会导致问题。有大量关于类似问题的文档,但它仅与 IIS 托管服务相关(我们的服务是从 Windows 服务自托管的):
IIS7 - (413) Request Entity Too Large | uploadReadAheadSize
有人知道仅适用于自托管 WCF 服务的等效设置吗?
最佳答案
由于这篇看似无关的帖子,我发现了问题:
http://forums.newatlanta.com/messages.cfm?threadid=554611A2-E03F-43DB-92F996F4B6222BC0&#top
这绝对是 SSL 问题,与将 SSL 证书绑定(bind)到您托管的端口有关。您必须使用 netsh 绑定(bind)证书并将 clientcertnegotiation=enable 添加到绑定(bind)中。
在我们的例子中,我们已经使用了 netsh,因为我们使用了不同的端口,所以我们的绑定(bind)现在看起来像这样:
netsh http add sslcert ipport=0.0.0.0:10100 certhash=000000089A6679262D845B650FDDE5390F0D86AB appid={000007b4-2d4b-4587-ae99-7a6627476f76} clientcertnegotiation=enable
对于通过 IIS 托管并更改 UploadReadAheadSize 值的用户,上面的论坛帖子指出这可能会导致 CPU 过高,而此解决方案可能会更好。
关于WCF 413 请求实体太大 - 自托管 WebHttpBinding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22200031/
我正在尝试将客户端证书应用于 WCF REST 服务。我发现了一些有关应用具有以下内容的客户端证书的详细信息: 在这种
我创建了一个 Web 服务,我试图为其提供 3 个具有不同绑定(bind)的端点。 1.基本的HttpBinding, 2.wsHttpBinding, 3.webHttpBinding 当我进行服务
我已经创建了一个 RESTful 服务并实现了身份验证。它接受用户名和密码,然后授予对所请求服务的访问权限。它工作正常。现在我想在我的服务之上使用 SSL。为此我创建了证书,然后在 IIS 中我给出了
在我的 WCF 服务中,我试图通过 SSL 连接使用 JSON 将数据发送到客户端。我能够使用 wsHttpBinding 和 Transport 安全模式将 OData 数据库源保护到我的客户端。为
会不会像 [OperationContract] [WebGet] string IWannaRead(int[] ids); 工作?以及如何为请求形成链接\url (www.
我有一个 WCF REST 服务。我想为操作编写集成测试。我正在考虑使用 HttpWebRequest 来编写这些内容(如 Why does my C# client, POSTing to my W
我正在使用 Android 客户端将文件上传到 wcf 服务。上传工作正常,但现在我想在请求中获取文件名和另一个整数参数。 我该怎么做? afaik,我不能使用消息协定,因为我没有将消息打包为 SOA
引用我的previous question ,我想知道如果该服务仅公开一个使用 webHttpBinding 的端点,我将如何从客户端应用程序中提取 WCF 服务的信息以了解公开了哪些方法/类型? 总
我是 WCF RESTFull 服务开发的新手,我正在寻找一些有用的信息以及与新的 WCF Web API http://wcf.codeplex.com/ 相比使用 webHttpBinding 的
关于这个问题有很多讨论,但是我现在已经尝试了所有可能的解决方案,但我们仍然从服务器收到 413 Request Entity Too Large 错误。 我们的 WCF 服务是通过 Azure Wor
关于这个问题有很多讨论,但是我现在已经尝试了所有可能的解决方案,但我们仍然从服务器收到 413 Request Entity Too Large 错误。 我们的 WCF 服务是通过 Azure Wor
我正在使用 C# 和 .NET Framework 4.0 开发 WCF 服务。 我正在使用 webHttpBinding 来执行此操作: [OperationContract] [WebInvoke
我添加了对“System.ServiceModel”库的引用,但“WebHttpBinding”类不在其中。根据文档,它应该在那里 ( WebHttpBinding )。我在 3.5 和 4.0 框架
我有一个 REST WCF 服务。它使用 webHttpBinding 并且配置如下所示: CustomMapper 用于应用自定义 WebContentTypeMapper,我尝试如下
在引用 .NET 4.0 的 System.ServiceModel 和 System.ServiceModel.Web 库时,我无法实例化 WebHttpBinding 类。我可以在引用 3.5 库
我创建了一个 WCF 服务并公开了三个端点,它们是 basicHttpBinding、wsHttpBinding 和 webHttpBinding。这是我使用 WCF 进行实验的测试服务。但是,每当我
我正在尝试为网站使用 https 和 http。该网站具有充当 REST 服务并从 JavaScript 调用的 .svc 文件。 我的配置:
我正在开发 WPF 需要认证的应用程序。我想用客户端应用服务使用 ASP.Net 成员(member)提供商 (如果您不知道我在说什么,请参阅此 link)。实际上,我基于 MembershipPro
在 WCF 中,有几种不同类型的基于 HTTP 的绑定(bind): BasicHttpBinding WsHttpBinding WebHttpBinding 这三个有什么区别? 特别是在功能/性能
我正在尝试使用默认的 WebHttpBinding 绑定(bind) POST 到 REST 服务。该服务仅接受“text/xml”作为内容类型,WebHttpBinding 正在发送“applica
我是一名优秀的程序员,十分优秀!