When connecting to a web service sometimes you may get following exception or similar:
"Content Type text/xml; charset=utf-8 was not supported by service http://localhost:8000/calculator. The client and service bindings may be mismatched."
Problem Description
To avoid this problem, usually it seem to be enough to change the property 'textMessageEncoding' of for example BasicHttpBinding. Unfortunately, this property specifies the kind of message-encoding and not the kind of text-encoding. It menas it can take valueslike MTOM, Text, Binary or even Json.
To specify the right text encoding you will have to define a custom binding like shown at picture below:
This would be helpful as long the required encoding is one of WCF-supported recordings. Following code snippet shows
how WCF internally defines supported recordings:
static TextEncoderDefaults()
{
Encoding = Encoding.GetEncoding("utf-8");
SupportedEncodings = new Encoding[] { Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode };
CharSetEncodings = new CharSetEncoding[]
{
new CharSetEncoding("utf-8", Encoding.UTF8),
new CharSetEncoding("utf-16LE", Encoding.Unicode),
new CharSetEncoding("utf-16BE", Encoding.BigEndianUnicode),
new CharSetEncoding("utf-16", null),
new CharSetEncoding(null, null) };
}
As you see there are just few supported encoding. In other words, if you have a service which requires ISO-8859-1, this will not work.
To solve this problem I wrote the custom encoder which supports many other encoding. Here are some examples:
EUCCN, EUCJP
EUCKR
GB18030
ISCIIAssemese
ISCIIBengali
ISCIIDevanagari
ISCIIGujarathi
ISCIIKannada
ISCIIMalayalam
ISCIIOriya
ISCIIPanjabi
ISCIITamil
ISCIITelugu
ISO_8859_1
ISO_8859_8_Visual
ISO_8859_8I
ISO2022JP
ISO2022JPESC
ISO2022JPSISO
ISOKorean
ISOSimplifiedCN
latin1Encoding
Solution
1. Go to following link an download the DLL which supports all encoding listed above.
2. Add reference to downloaded assembly Daenet.MessageEncoder.Dll.
3. Extend client's configuration file as shown below:
Posted
Apr 18 2008, 11:52 PM
by
Damir Dobric