I have written a client to a web service. I use ASP.NET 1.1 for the
client.
It worked until I tried to send accented characters. Then the service
answered that my signature is not valid. I was told by the people
running the service that their host takes ISO-8859-1 (Latin1) and
nothing else.
I had been sending the default UTF-8. I tried to send Latin1 with this:
RequestEncoding= System.Text.Encoding.GetEncoding( "ISO-8859-1");
in the proxy class.
I tried and it seemed to work, because it had deleted all the accented
characters! Thus the service had no problem to validate the signature.
It had written <?xml version="1.0" encoding="iso-8859-1"?> and the
ContentType was the desired "text/xml; charset=iso-8859-1".
Reading from "GotDotNet User Sample: Encoding SOAP extension" (
http://www.gotdotnet.com/Community/U...d-5186106eb57c
) (including the little comment at the bottom), I added a
SoapExtension that goes before the rest of extensions (those that log a
copy, add a signature,...)
I did things like this:
if( SoapMessageStage.AfterSerialize== message.Stage)
{
if( inwardStream.CanSeek)
{
inwardStream.Position= 0;
}
Regex expReg= new Regex(
System.Text.Encoding.UTF8.HeaderName /* utf-8 */,
RegexOptions.IgnoreCase);
TextReader lector= new StreamReader( inwardStream);
TextWriter escritor;
escritor= new StreamWriter(
// _encoding is "iso-8859-1"
outwardStream, System.Text.Encoding.GetEncoding( _encoding));
SoapMsgTxt= expReg.Replace( SoapMsgTxt, _encoding);
escritor.Flush();
}
It substituted in <?xml ?> but when the next SoapExtension converted
its stream to a string, the accented characters had disappeared.
Then I tried:
escritor= new XmlTextWriter( outwardStream,
System.Text.Encoding.GetEncoding( _encoding));
XmlDocument doc= new XmlDocument();
//SoapMsgTxt is the SOAP XML in a string, read from the stream
doc.LoadXml( SoapMsgTxt);
doc.WriteTo( escritor);
And it appeared mutilated again.
I also tried:
escritor.WriteRaw( SoapMsgTxt);
and even:
if( SoapMessageStage.BeforeSerialize== message.Stage)
{
message.ContentType= "text/xml; charset=iso-8859-1";
// I can call the base. I am inheriting from a subclass
// of SoapExtension
base.ProcessMessage( message);
}
It kept mutilating characters.
Any suggestion on how I can convert my Request to ISO-8859-1?
Thanks in advance.
--
David Mediavilla <6k*******@sneakemail.com>