Title: We were short for time and there were other interesting features to consider
Slug: we-were-short-for-time-and-there-were-other-interesting-features-to-consider
Date: 2007-07-16 15:22:00
Author: Kartones
Lang: en
Tags: Development, XML, ASP.NET, .NET
Description: Challenges faced in changing the XML encoding of an ASP.NET Web Service to handle special characters.

 <p>Today I was building a <a href="http://en.wikipedia.org/wiki/Mock_object">mock</a> of an ASP.NET Web Service for my current project, and I had some problems reading XML with spanish characters ('ñ' for example). <br>I tried changing the <font color="#800000" face="Courier New">&lt;globalization&gt;</font> tag of the Web.Config to use an international encoding but it didn't work.<br>I tried forcing the WS encoding from C# code, but it didn't work either...</p> <p>After some digging, I found <a href="http://forums.asp.net/p/1109783/1707421.aspx">this "fantastic" explanation</a>:</p> <p><i>According to comment written by a member of the MS team there is no way to change ASMX encoding.</i>  </p><p><i>We decided not to do this feature for 3 reasons: <br>1. UTF-8 can represent all Unicode characters <br>2. The Xml spec requires that all Xml processors understand UTF-8 <br><b>3. We were short for time and there were other interesting features to consider.</b></i></p> <p>Cool, now I have one good excuse for the next time we're in a rush and we have to get something finished "for yesterday" :D</p> <p>So, If you want to change the XML response encoding from a WS from UTF-8 to another encoding... forget doing it from .NET ;)</p>
