我有一个简单的Web服务,它需要2个参数,一个是简单的xml安全令牌,另一个通常是一个长xml字符串。它适用于短字符串,但更长的字符串会提供400错误消息。 maxMessageLength没有做任何事情来允许更长的字符串。WCF - 如何接受长字符串作为参数
3
A
回答
2
您应该删除配额限制。 这里是你如何使用Tcp绑定来完成代码。 我添加了一些代码,显示删除超时问题,因为通常发送非常大的参数会导致超时问题。所以明智地使用代码... 当然,您也可以在配置文件中设置这些参数。
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);
// Allow big arguments on messages. Allow ~500 MB message.
binding.MaxReceivedMessageSize = 500 * 1024 * 1024;
// Allow unlimited time to send/receive a message.
// It also prevents closing idle sessions.
// From MSDN: To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.’
binding.ReceiveTimeout = TimeSpan.MaxValue;
binding.SendTimeout = TimeSpan.MaxValue;
XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
// Remove quotas limitations
quotas.MaxArrayLength = int.MaxValue;
quotas.MaxBytesPerRead = int.MaxValue;
quotas.MaxDepth = int.MaxValue;
quotas.MaxNameTableCharCount = int.MaxValue;
quotas.MaxStringContentLength = int.MaxValue;
binding.ReaderQuotas = quotas;
3
配额我只是做了所有在web.config
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IPayroll" maxReceivedMessageSize="6553600">
<security mode="None"/>
<readerQuotas maxDepth="32"
maxStringContentLength="6553600"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</wsHttpBinding>
</bindings>
相关问题
- 1. 将查询字符串参数添加到WCF服务操作接受流
- 2. 字符串作为参数
- 3. 如何在objc_msgSend()中传递直接字符串作为参数?
- 4. 如何使用GET传递连接字符串作为参数?
- 5. WCF太长的字符串
- 6. WCF接口作为参数
- 7. 字符串文字参数不被接受到constexpr函数
- 8. 为什么插入和子串字符串方法不接受无符号的64位整数作为参数?
- 9. Wcf post方法与长json字符串参数
- 10. WCF/Rest/UriTemplate可变长度查询字符串参数列表?
- 11. Erlang如何接受字符串?
- 12. 作为ASMX公开的WCF服务将不接受参数
- 13. NHibernate的 - 设置长字符串作为参数查询
- 14. ResourceBundle/Propertie文件接受参数{0}中的字符串数组
- 15. Grails日期被接受为字符串
- 16. 字符串参数间接
- 17. 如何传递字符串数组作为函数参数
- 18. 接受单字典或字典列表作为函数参数
- 19. 如何把字符串作为连接字符串到app.config?
- 20. 如何同时接受字符串或无参数以提升Python函数
- 21. 接受字符串值
- 22. 通过接受字符串
- 23. 如何使用字符串作为关键字参数?
- 24. 内置字符串格式与字符串连接作为日志参数
- 25. 通字符串作为参数
- 26. 传递字符串作为参数
- 27. 以参数作为字符串
- 28. 参数化查询作为字符串
- 29. SQL添加字符串作为参数
- 30. 字符串作为参数(C++)
多久了您的字符串的回答后?你用什么合同? 我有MessageContract和字符串是64k字符长。 – Tuoski 2009-09-09 13:51:05