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 02, 2004 11:10 PM by Tim Marman

Comments

# re: Encoding limitations in ASMX

Tuesday, February 03, 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 03, 2004 2:35 PM by Tim Marman
Interesting.

What about the latin characters?

# re: Encoding limitations in ASMX

Saturday, April 03, 2004 5:39 PM by Madhu
Hi

# Vuoi cambiare encoding per un WebService? Non si pu

Monday, June 12, 2006 9:54 AM by FoxyBlog

# Vuoi cambiare encoding per un WebService? Non si pu

Monday, June 12, 2006 9:55 AM by FoxyBlog

# re: Encoding limitations in ASMX

Sunday, August 05, 2007 4:25 PM by hiswife

<a href=" ggcoll.info/.../nc-state-employees-credit-union.html ">nc state employees credit union</a> <a href=" ddcoll.info/.../payday-loan-illinois.html ">payday loan illinois</a> <a href=" iiadv.biz/.../best-motorcycle-insurance.html ">best motorcycle insurance</a> <a href=" yyadv.biz/.../engineer-insurance.html ">engineer insurance</a> <a href=" qqadv.biz/.../gieco-insurance.html ">gieco insurance</a>

Leave a Comment

(required) 
(required) 
(optional)
(required)