System.Text.UTF8Encoding converter = new System.Text.UTF8Encoding();
byte[] buffer = converter.GetBytes(outerXml);
using (MemoryStream ms = new MemoryStream())
{
using (GZipStream gzip = new GZipStream(ms, CompressionMode.Compress))
{
gzip.Write(buffer, 0, buffer.Length);
}
buffer = ms.ToArray();
}