WCF: Text Message Encoding and ISO-8859-1 Encoding(msmvps.com)

submitted by PauloMorgadoPauloMorgado(435) 4 years, 9 months ago

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.

add a comment |category: |Views: 244

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story