0
I have this string
:
EM RECUPERA�?�?O
This string comes to me in a XML
and I use the following code to treat that:
byte[] bytes = Encoding.Default.GetBytes(xmlRetorno);
xmlRetorno = Encoding.UTF8.GetString(bytes);
But it’s not working. It’s still the same.
So I return the XML:
public string EnviarXmlSoap(string methodName, string body, string url)
{
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest httpRequest = (HttpWebRequest)webRequest;
httpRequest.Method = "POST";
httpRequest.ContentType = "text/xml; charset=utf-8";
httpRequest.Headers.Add("SOAPAction: http://tempuri.org/" + methodName);
httpRequest.ProtocolVersion = HttpVersion.Version11;
httpRequest.Credentials = CredentialCache.DefaultCredentials;
Stream requestStream = httpRequest.GetRequestStream();
//Create Stream and Complete Request
StreamWriter streamWriter = new StreamWriter(requestStream, Encoding.UTF8);
StringBuilder soapRequest = new StringBuilder("<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
soapRequest.Append(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ");
soapRequest.Append("xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:"+methodName+"\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"> <soapenv:Header/> <soapenv:Body>");
soapRequest.Append(body);
soapRequest.Append("</soapenv:Body></soapenv:Envelope>");
streamWriter.Write(soapRequest.ToString());
streamWriter.Close();
string xml = soapRequest.ToString();
//Get the Response
HttpWebResponse wr = (HttpWebResponse)httpRequest.GetResponse();
StreamReader srd = new StreamReader(wr.GetResponseStream());
string resulXmlFromWebService = srd.ReadToEnd();
return resulXmlFromWebService;
}
what code retrieves this
XML
? it seems to me that the error is before and not at this time. If you can put the code in the question !– novic
Inside XML is with normal characters or with this
�?
? It is better you add in question the way you download this file, possibly the problem is in the download and not in the way to open, as it happens in that question– Jéf Bueno
I tested it in Soap UI and the xml comes like this...
– novato
@Newbie as you make the rescue code of
xml
?– novic
@newcomer I believe that the
.ToString
is occurring this. take the return ofXML
in avar
and use a method that redeems theXML
, in my case in sending and returnXML
I use schemas to serialize and say the same with patternsunicode
andencoding
. Do it just for testing.– Daniel Nicodemos
@newbie is think it’s coding Webservice, maybe it’s another coding has to research it.
– novic