Add row header in xml when enveloping

0

I use this function to add rows to envelop xml :

 string soapEnvelope = string.Empty;
       soapEnvelope += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ws=\"http://www.betha.com.br/e-nota-contribuinte-ws\" xmlns:xd=\"http://www.w3.org/2000/09/xmldsig#\">";
        soapEnvelope += "<soapenv:Header/><soapenv:Body><ws:gerarNfse>";
        soapEnvelope += document.LastChild.OuterXml.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", string.Empty);
       soapEnvelope += "</ws:gerarNfse></soapenv:Body></soapenv:Envelope>";
        MemoryStream stream = stringToStream(soapEnvelope);
        webRequest.ContentLength = stream.Length;
        Stream requestStream = webRequest.GetRequestStream();
        stream.WriteTo(requestStream);

        document.LoadXml(soapEnvelope);
        document.PreserveWhitespace = false;

But I need to add this line of this variable:

 private string CabecMsg = "<cabecalho xmlns=\"http://www.betha.com.br/e-nota-contribuinte-ws\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>";

I tried to include soon after, soapEnvelope += "</ws:gerarNfse></soapenv:Body></soapenv:Envelope>"; but it returns me error, it needs to stay after the line </ws:gerarNfse> and before closing soapenv . How can I solve?

    
asked by anonymous 11.12.2018 / 13:52

0 answers