如何使用 C# 压缩消息并使用 javascript 解压缩消息?
我有一个 WCF 服务,我想发送一条包含尽可能少字符的消息。
有没有任何压缩方法可以做到这一点?
我想用 C# 压缩它并使用 javascript 解压缩它。
I have a WCF Service and I want to send a message with the least characters possible.
Are there any compression methods to do this?
I want to compress it in C# and decompress it using javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MTOM。
或者,您可以实现自定义消息编码器和解码器,在其中通过(解)压缩引擎传递数据。这意味着您可以控制两端(客户端和服务)。
不幸的是,我不知道您更新的问题的答案。您必须找到一些在 C# 和 Javascript 中实现相同压缩算法的库。我从来没有做过这样的事情,所以我不知道该使用哪些库。您可以尝试手动实现 LZW 或 DEFLATE 之类的东西,但这将是困难的方法并且容易出错。
MTOM.
Or you could implement a custom message encoder and decoder, where you pass the data through a (de)compression engine. This implies you have control over both ends (client and service).
Unfortunately I don't know the answer to your updated question. You'd have to find some libraries that implement the same compression algorithm in both C# and Javascript. I've never done anything like that so I wouldn't know which libraries to use. You could try to manually implement something like LZW or DEFLATE, but that'll be the hard way and error-prone.
为此,您可以实现此处。
For that, you might implement one of the compression techniques explained here.