String compression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone point me to some code (that functions) on how to compress strings in C#. We need this to speed up out WebServices/MessageQueue applications and so far what little code we found has not worked. A URL would do nicely. Thanks.
 
Hello,

Can you please explain what you are looking for.
-----Original Message-----
Can someone point me to some code (that functions) on how
to compress strings in C#. We need this to speed up out
WebServices/MessageQueue applications and so far what
little code we found has not worked. A URL would do
nicely. Thanks.
 
I'm looking for code on how to compress a (XML) string to send through a WebService. Due to the size of the data we are sending it takes an unacceptable amount of time to accomplish the task. If we can compress the string into a string then we can speed up the task and make eveyone happy.
 
Hi,

The best way of doing it would be create a ZIP and send the zip, now, I
don;t think that you can send a binary stream using a webservice, if not the
the zip stream should be converted and sent as text. and then decompress in
the receiving, I think that this solution should be faster than sending the
XML per se, but there are better solutions like:

1- Using remoting with a binary encoding and the TcpChannel.
2- If you don;t wanna use remoting you can make a Tcp connection and send
the binary stream.

Now, you could also persist the stream to a file and then send this file as
many times as needed, this allow you to decouple the generation of the data
and the sending operation.


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


skg said:
I'm looking for code on how to compress a (XML) string to send through a
WebService. Due to the size of the data we are sending it takes an
unacceptable amount of time to accomplish the task. If we can compress the
string into a string then we can speed up the task and make eveyone happy.
 
I am not sure it is suitable in your case, but you can employ a ZIP library
(I am pretty sure there is even a free one written in C#) to compress the
string. But you should also change the Web service to make it decompress the
received data before processing them. Of course you can only compress the
data themselves, the SOAP envelope around the request should be left intact
as I am not aware of any Web Service extension allowing compressed SOAP
requests. This doesn't mean however such extension cannot exists, Web
Services are just not my primary speciality.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

skg said:
I'm looking for code on how to compress a (XML) string to send through a
WebService. Due to the size of the data we are sending it takes an
unacceptable amount of time to accomplish the task. If we can compress the
string into a string then we can speed up the task and make eveyone happy.
 
There is a problem with this. If you want to still use Web Services,
then you will have to encode the binary attachments as base 64, or use DIME
(which is being deprecated as well). If you go the base64 route, whatever
binary you create is going to be represented in approximately 4/3 the size
of the original binary (larger), and that has to be wrapped in an XML
payload which is transmitted to the web service.

Basically, you will have to perform a calculation to determine if the
overall size of the payload is larger or smaller than what it would be
compressed, encoded, and wrapped in a call to another web service. Not
exactly the easiest of things.

To be honest, I think that the OP might have better luck optimizing the
performance of the code that the web service runs, instead of going this
route.

Also, it should be mentioned that there is a lot of talk regarding a
"binary infoset" for the purposes of efficiency.

Hope this helps.
 
Nicholas Paldino said:
There is a problem with this. If you want to still use Web Services,
then you will have to encode the binary attachments as base 64, or use DIME
(which is being deprecated as well). If you go the base64 route, whatever
binary you create is going to be represented in approximately 4/3 the size
of the original binary (larger), and that has to be wrapped in an XML
payload which is transmitted to the web service.

Absolutely, if a web service is a MUST then the benefits will only be reals
if the XML is big, A test I just did; I have a DataSet of 1.5MB, compacted
it's 108Kb, so it would be transmited as a 144Kb file , a big improvement
from the 1.5 original file.

Cheers,
 
Before WebServices were around, (and before VS.net), we had to put together
something that was basically a (pre-spec) web service. that is, we had to
post an xml string to a web server to invoke an action on the server that
involved posting a lot of data to a database.

We did it by building the XML message, zipping it, then base64 encoding the
zip. Then we embedded that base64-encoded string inside of a very simple
XML envelope. I wouldnt' bother for small messages, but if you're sending,
for example, a 1 meg collection of rows, it can be useful.

In those days we had to compress to file and then operate on the file.
However, I beleive that there are some .Net compression libraries (DynaZip,
for one) that support in-memory stream compression.

The downer is that with today's "real" web services, I would imagine that
you lose the automatic proxy generation and such -- that compressed, encoded
XML blob probably only looks like a string to WSDL.


skg said:
Can someone point me to some code (that functions) on how to compress
strings in C#. We need this to speed up out WebServices/MessageQueue
applications and so far what little code we found has not worked. A URL
would do nicely. Thanks.
 
Back
Top