473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 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 9224
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.