Encoding limitations in ASMX

You can specify the encoding to be used when consuming a Web Service from .NET (the SoapHttpClientProtocol object has a RequestEncoding property).

Unfortunately, you don't have that ability on the ASMX service itself - it is hard-coded to UTF-8. As a result, you won't be able to consume a service with MSXML3 if you return Unicode characters, etc (ie anything that's not UTF-8).

I've tried changing the globalization configuration and explicitly setting the headers on the response stream to no avail. I found a somewhat reasonable solution via the newsgroups - to implement a SoapExtension that does a string replacement on the output stream. Obviously, there are some issues with efficiency and scalability when you're doing this.

Can someone explain why I can't just do this?

[WebMethod(Encoding="Unicode")]

Hmm...

Published Monday, February 2, 2004 11:10 PM by Tim Marman

Comments

# re: Encoding limitations in ASMX

Tuesday, February 3, 2004 12:32 PM by AlexDej
We decided not to do this feature for 3 reasons:
1. UTF-8 can represent all Unicode characters
2. The Xml spec requires that all Xml processors understand UTF-8
3. We were short for time and there were other interesting features to consider.

We found out later that in the real world #2 just isn't the case. If we'd known that we probably would have made a different decision.

# re: Encoding limitations in ASMX

Tuesday, February 3, 2004 2:35 PM by Tim Marman
Interesting.

What about the latin characters?

# re: Encoding limitations in ASMX

Friday, December 5, 2008 10:16 PM by Semil

<a href= spiritez.com ></a>