我有一个WCF服务,现在必须以这种编码方式发送数据:iso-8859-1。
我尝试更改IIS配置或在配置中添加全球化应用程序,但服务的响应始终为UTF-8。
有人能帮助我吗?
感谢。
答案 0 :(得分:0)
您无法在WCF中开箱即用。有关如何创建支持ISO-8859-1的自定义绑定的一些详细信息,请参阅此答案:https://stackoverflow.com/a/1908154/2420979
答案 1 :(得分:0)
我为框架4.0下载了CustomTextMessageEncoder,我成功显示了svc页面,但我的所有调用都没有返回任何内容,并且不显示其余服务的HELP应答器。
我还注意到,当我调用我的本地服务时,它执行该方法两次而没有最终结果,但如果我将绑定更改为webHttpBinding,我执行该方法一次并且它可以正常工作
这是我的配置:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="TestTheIso.Service1" behaviorConfiguration="ServiceBehaviour">
<endpoint binding="customBinding" bindingConfiguration="DefaultBinding" contract="TestTheIso.IService1" behaviorConfiguration="toto">
</endpoint>
</service>
</services>
<bindings>
<customBinding>
<binding name="DefaultBinding">
<customTextMessageEncoding encoding="ISO-8859-1" messageVersion="None" />
<httpTransport manualAddressing="true"/>
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="toto">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<extensions>
<bindingElementExtensions>
<add name="customTextMessageEncoding"
type="Microsoft.Samples.CustomTextMessageEncoder.CustomTextMessageEncodingElement, CustomTextMessageEncoder"/>
</bindingElementExtensions>
</extensions>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>