Possible duplicate:
Calling a web service that uses ISO-8859-1 encoding from WCF
I am trying to use an external web service (the web service has a PHP implementation) using VS 2008, .net 3.5, WCF (environment: Windows XP and VS 2008). I am adding a service link to a web service, VS generates a WCF proxy.
Binding is the base HTTPbinding.
I call a method in a web service using a proxy, then I started to get a ProtocolException, I got the following error message:
System.ServiceModel.ProtocolException: Content Type text / xml; charset = ISO-8859-1 response message does not match the content binding type (text / xml; encoding = UTF-8). If you use an encoder, make sure that the IsContentTypeSupported Method is correctly implemented.
The first 644 bytes of the response were:
It was successful
Well, I needed to call the service in iso-8859-1 encoding.
Any useful source code example to solve it?
Update:
The default encoder used in WCF only works with UTF-8 and UTF-16 (large and small endian).
If I use textEncoding = "iso-8859-1" in the binding in app.config,
I get this error:
System.ArgumentException: not allowed la codificación de texto 'iso-8859-1' usada en el formato de mensaje de Texto. Nombre del parámetro: coding.
System.ServiceModel.Channels.TextEncoderDefaults.ValidateEncoding( ) System.ServiceModel.Channels.TextMessageEncodingBindingElement.set_WriteEncoding ( ) System.ServiceModel.BasicHttpBinding.set_TextEncoding ( ) System.ServiceModel.Configuration.BasicHttpBindingElement.OnApplyConfiguration(Binding ) System.ServiceModel.Configuration.StandardBindingElement.ApplyConfiguration(Binding ) System.ServiceModel.Description.ConfigLoader.LookupBinding(String bindingSectionName, String configName, ContextInformation ) System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String ConfigurationName) System.ServiceModel.ChannelFactory.ApplyConfiguration(String ConfigurationName) System.ServiceModel.ChannelFactory.InitializeEndpoint(String _, Address ) ctor (String endpointConfigurationName, EndAdAddress remoteAddress) CreateSimplexFactory() CreateChannelFactory() CreateChannelFactoryRef (EndpointTrait`1 endpointTrait) InitializeChannelFactoryRef() ctor() IntegracionEasyVista.ServiceEasyVista.WebServicePortTypeClient..ctor()
Update:
-, ISO-8859-1 WCF
-, ISO-8859-1 WCF
MSDN (http://msdn.microsoft.com/en-us/library/ms751486(v=VS.90).aspx) , "CustomTextEncoder", , utf-8, utf- 16 Unicode. , .
CustomTextMessageEncodingElement, :
text/xml; charset = ISO-8859-1 (text/xml; charset = iso-8859-1). , , IsContentTypeSupported . 1024 : **
MSDN CustomTextMessageEncoder:
public CustomTextMessageEncoder(CustomTextMessageEncoderFactory factory)
{
writerSettings = new XmlWriterSettings();
writerSettings.Encoding = Encoding.GetEncoding(factory.CharSet);
contentType = string.Format("{0};charset={1}",
factory.MediaType, this.writerSettings.Encoding.HeaderName);
}
"{0}; charset = {1}" "{0}; charset = {1}" ( )
:
(Soap11 (http://schemas.xmlsoap.org/soap/envelope/) AddressingNone
( http://schemas.microsoft.com/ws/2005/05/addressing/none))
(Soap12 ( http://www.w3.org/2003/05/soap-envelope) Addressing10 ( http://www.w3.org/2005/08/addressing)).
, , .