简体   繁体   English

线上的Silverlight二进制序列化

[英]Silverlight Binary Serialization over the wire

While nearly completing a new release, we've ignored the large size of the XML data that our WCF service returns to our silverlight client. 在接近完成一个新版本的同时,我们已经忽略了WCF服务返回给我们的Silverlight客户端的大量XML数据。 Now we're investigating how to shrink the data, so that the results aren't in the 10-100mb range. 现在我们正在研究如何缩小数据,以使结果不在10-100mb范围内。

Its seems clear that binary serialization is the solution, and it seems easy enough to serialize the data into binary with, for instance, SharpSerializer, but through all of the SO posts about binary serialization and other tutorials I've come across, no one addresses how to send the serialized data across the wire to the Client. 似乎很清楚二进制序列化是解决方案,并且看起来很容易使用例如SharpSerializer将数据序列化为二进制,但是通过所有有关二进制序列化的SO帖子以及我遇到的其他教程,没有人解决如何通过电线将序列化数据发送到客户端。 I expect I'm missing some obvious but critical piece to the WCF service puzzle. 我希望我缺少WCF服务难题中一些显而易见但至关重要的部分。

Hopefully someone can lend me some help. 希望有人可以帮助我。 Let me know if I should include more information. 让我知道是否应提供更多信息。

First, try the built-in binary encoding (<binaryMessageEncoding> in config, see http://www.mostlydevelopers.com/blog/post/2009/10/14/Silverlight-3-WCF-Binary-Message-Encoding.aspx and http://www.silverlight.net/learn/data-networking/network-services-(soap,-rest-and-more)/how-do-i-use-binary-encoding-for-wcf-with-silverlight-3 ). 首先,尝试使用内置的二进制编码(配置中的<binaryMessageEncoding>,请参阅http://www.mostlydevelopers.com/blog/post/2009/10/14/Silverlight-3-WCF-Binary-Message-Encoding.aspxhttp://www.silverlight.net/learn/data-networking/network-services-(soap,-rest-and-more)/how-do-i-use-binary-encoding-for-wcf-with- silverlight-3 )。

Your data will probably shrink, but please note that the built-in binary encoding was designed to be as fast as possible, not as small as possible. 您的数据可能会缩小,但是请注意,内置的二进制编码被设计为尽可能快,而不是尽可能小。

If that's not enough and you want to use a 3rd=party component to do the serialization to binary data, you can indeed return this data as a byte[] (but you will also need to use <binaryMessageEncoding> above to prevent WCF from base64-encoding the data to make it valid XML). 如果这还不够,并且您想使用3rd = party组件对二进制数据进行序列化,则确实可以将该数据作为字节[]返回(但您还需要使用上述<binaryMessageEncoding>来防止WCF来自base64 -对数据进行编码以使其成为有效的XML)。 You can also use Stream instead of byte[], this won't give you true streaming behavior on the Silverlight client side but can give you true streaming on the server side. 您也可以使用Stream代替byte [],这不会在Silverlight客户端上为您提供真正的流式传输行为,但可以在服务器端上为您提供真正的流式传输。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM