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...

3 Comments

Comments have been disabled for this content.