472,805 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Change character encoding in the Request

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>

Nov 23 '05 #1
6 9181
I forgot that I also tried changing <globalization /> in the web.config
just in case. But it doesn't work on the service, only on the ASP.NET
forms.

--
David Mediavilla

Nov 23 '05 #2
I forgot that I also tried changing <globalization /> in the web.config
just in case. But it doesn't work on the service, only on the ASP.NET
forms.

--
David Mediavilla

Nov 23 '05 #3
I removed the special SoapExtension and changed in the base class of my
SoapExtensions:

case SoapMessageStage.BeforeDeserialize:
readStr = new StreamReader(outwardStream,
System.Text.Encoding.GetEncoding( "ISO-8859-1"));
SoapMsgTxt = readStr.ReadToEnd();
writeStr = new StreamWriter(
inwardStream, readStr.CurrentEncoding);
//[...]

case SoapMessageStage.AfterSerialize:
inwardStream.Position = 0;
readStr = new StreamReader(inwardStream,
System.Text.Encoding.GetEncoding( "ISO-8859-1"));
SoapMsgTxt = readStr.ReadToEnd();
writeStr = new StreamWriter(
outwardStream, readStr.CurrentEncoding);

while setting RequestEncoding to ISO-8859-1.

It still removes accented characters.

ISO-8859-15 behaves as -1.

Setting RequestEncoding to AsciiEncoding, however, substitutes accented
characters by question marks.

--
David Mediavilla

Nov 23 '05 #4
I removed the special SoapExtension and changed in the base class of my
SoapExtensions:

case SoapMessageStage.BeforeDeserialize:
readStr = new StreamReader(outwardStream,
System.Text.Encoding.GetEncoding( "ISO-8859-1"));
SoapMsgTxt = readStr.ReadToEnd();
writeStr = new StreamWriter(
inwardStream, readStr.CurrentEncoding);
//[...]

case SoapMessageStage.AfterSerialize:
inwardStream.Position = 0;
readStr = new StreamReader(inwardStream,
System.Text.Encoding.GetEncoding( "ISO-8859-1"));
SoapMsgTxt = readStr.ReadToEnd();
writeStr = new StreamWriter(
outwardStream, readStr.CurrentEncoding);

while setting RequestEncoding to ISO-8859-1.

It still removes accented characters.

ISO-8859-15 behaves as -1.

Setting RequestEncoding to AsciiEncoding, however, substitutes accented
characters by question marks.

--
David Mediavilla

Nov 23 '05 #5
I removed all the SoapExtensions from web.config, set RequestEncoding
to ISO-8859-1, and looked at the HTTP traffic with ProxyTrace. This
time the accented characters were conserved in the transmision. So
something in the SoapExtensions damages them.

I also tried the application in Visual Studio 2005 Beta 2.
Setting RequestEncoding to ISO-8859-1, instead of removing the accented
characters converts them to question marks.

--
David Mediavilla

Nov 23 '05 #6
I removed all the SoapExtensions from web.config, set RequestEncoding
to ISO-8859-1, and looked at the HTTP traffic with ProxyTrace. This
time the accented characters were conserved in the transmision. So
something in the SoapExtensions damages them.

I also tried the application in Visual Studio 2005 Beta 2.
Setting RequestEncoding to ISO-8859-1, instead of removing the accented
characters converts them to question marks.

--
David Mediavilla

Nov 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: knocker | last post by:
Hi I have a problem with JSP on websphere 5. When I try save information with swedish or danish characters, the string is cut where the first of these characters occurs. The JDK used is...
5
by: lkrubner | last post by:
I'm worried about idiot users that write long essays in Microsoft Word, then log into their accounts and bring up an HTML form and copy and paste the essay and hit submit. Or perhaps they do this...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
4
by: HeroOfSpielburg | last post by:
Hello, I am trying to using the Shift_JIS character set in my web pages, and have specified it as such in the <head>. <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> ...
6
by: Pavils Jurjans | last post by:
Hello, I am experiencing a weird behaviour on my ASP.NET project. The project consists from client-side, which can be whatever environment - web page, EXE application, etc. The client sends HTTP...
18
by: james | last post by:
Hi, I am loading a CSV file ( Comma Seperated Value) into a Richtext box. I have a routine that splits the data up when it hits the "," and then copies the results into a listbox. The data also...
0
by: 6kjfsyg02 | last post by:
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...
44
by: Kulgan | last post by:
Hi I am struggling to find definitive information on how IE 5.5, 6 and 7 handle character input (I am happy with the display of text). I have two main questions: 1. Does IE automaticall...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
2
by: Vladimir Ghetau | last post by:
Hi guys, This is a weird problem, and I'm not sure if I got it right. Just a practical example, that will describe my problem: I'm connecting to google.com host on port 80 using fsock open,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.