Im a long time trying to solve one problem. I have one method that Serialize a string, follows the code:
XmlRetorno()
        var algumasDef = new XmlWriterSettings {
            Indent = true, 
            OmitXmlDeclaration = true
        };
        var nameSpace = new XmlSerializerNamespaces();
        nameSpace.Add(string.Empty, "urn:sngpc-schema");
        var meuXml = new XmlSerializer(GetType(), "urn:sngpc-schema"); 
        using (var minhaString = new StringWriterWithEncoding(Encoding.GetEncoding("iso-8859-1"))) {
            using (var escreve = XmlWriter.Create(minhaString, algumasDef)) {
                meuXml.Serialize(escreve, this, nameSpace);
            }
            return minhaString.ToString();
        }
Then, my next step is to compact that string to a zip file, my method to zip.
CompactXml()
        string ziparEssaString = msg.XmlRetorno();
        byte[] byteArray = new byte[ziparEssaString.Length];
        int indexBA = 0;
        foreach (char item in ziparEssaString.ToArray()) {
            byteArray[indexBA++] = (byte)item;
        }
        //prepare to compress
        using (MemoryStream ms = new MemoryStream()) {
            using (GZipStream sw = new GZipStream(ms, CompressionMode.Compress)) {
                sw.Write(byteArray, 0, byteArray.Length);
            }
            //transform bytes[] zip to string
            byteArray = ms.ToArray();
            StringBuilder sB = new StringBuilder(byteArray.Length);
            foreach (byte item in byteArray) {
                sB.Append((char)item);
            }
            return sB.ToString();
        }
I need to compress a string that is formatted .xml and when I unpack I need the extension to be .xml too, my webservice return an error. Please, i need one light.
