Error!
Success!

WCF: Text Message Encoding and ISO-8859-1 Encoding

0
kicks

WCF: Text Message Encoding and ISO-8859-1 Encoding  (Unpublished)

I'm a newbie in WFC and, so far, only have done client code to call POX web services. I've been using a textMessageEncoding binding extension with a message version of None and a write encoding of utf-8 and all has been running fine. Well, until I needed to call a service in iso-8859-1 encoding. Then I started getting a ProtocolException: Message="The content type text/xml;charset=iso-8859-1 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. Bruno directed me to a sample that looked promising. The sample works fine because it's using the same binding extension in the server and in the client. When I tried to use the customTextMessageBinding from the sample, I got this nice ProtocolException: The content type text/xml;charset=iso-8859-1 of the response message does not match the content type of the binding (text/xml; charset=iso-8859-1). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. Looks kind of funny, doesn't it? It comes down to the fact that the base MessageEncoder class doing a string comparison on the content type. To solve this, I overrided the IsContentTypeSupported method and added an additional validadion when the validation fails. This new validation only checks for the media type of the response and lets the XmlReader handle the encoding.


Kicked By:
Drop Kicked By: