I need your help to solve a problem with a web service. I am consuming a WS with attachments. I do not have to get a valid answer and store them in a string, however when I want to pass this to XML I get an error because the response brings the following
My problem is that I can not save these in an XML document because it is not valid I need to truncate this to a valid XML ...
I leave the code as I invoke the WS
string xmlCompleto = postData.Trim();
//Documentxml.LoadXml(xmlCompleto);
string action = "doLogonUser";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://webservicesejemplo");
request.Method = "POST";
byte[] data = encoding.GetBytes(xmlCompleto);
//byte[] data = Encoding.UTF8.GetBytes(postData.ToString());
var myproxy = new WebProxy();
request.AllowWriteStreamBuffering = false;
//request.Headers.Add("SOAPAction", action);
request.ContentType = "text/xml; charset=utf-8";
request.Accept = "text/xml";
request.KeepAlive = false;
request.ContentLength = data.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(data, 0, data.Length);
dataStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
//Console.WriteLine(responseFromServer);
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
I'm desperate I can not solve this, I've searched for information but nothing yet.