C# 更改WCF响应编码
我有一个WCF服务,现在必须以这种编码发送数据:iso-8859-1 我试图更改IIS配置或在配置中添加全球化应答器,但服务的响应总是在UTF-8上 有人能帮我吗C# 更改WCF响应编码,c#,wcf,rest,encoding,iso-8859-1,C#,Wcf,Rest,Encoding,Iso 8859 1,我有一个WCF服务,现在必须以这种编码发送数据:iso-8859-1 我试图更改IIS配置或在配置中添加全球化应答器,但服务的响应总是在UTF-8上 有人能帮我吗 谢谢。在WCF中,您不能开箱即用。有关如何创建支持ISO-8859-1的自定义绑定的详细信息,请参阅此答案:我下载了适用于framework 4.0的CustomTextMessageEncoder,我成功显示了svc页面,但我所有的呼叫均未返回任何内容,rest服务也未显示帮助应答器 我还注意到,当我调用本地服务时,它会执行该方法两
谢谢。在WCF中,您不能开箱即用。有关如何创建支持ISO-8859-1的自定义绑定的详细信息,请参阅此答案:我下载了适用于framework 4.0的CustomTextMessageEncoder,我成功显示了svc页面,但我所有的呼叫均未返回任何内容,rest服务也未显示帮助应答器 我还注意到,当我调用本地服务时,它会执行该方法两次,但没有最终结果,但是如果我将绑定更改为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>
我看到了,但它更多地谈到了使用iso-8859-1编码的服务,但我试图公开这样工作的服务。绑定可以放在客户端或主机上。。。在这种情况下,您可能希望为您的服务主机使用相同的绑定。我们正在努力实现通过WCF REST下载CSV文件。该文件另存为BOM表UTF-8。但当在MS Excel中打开时,它会忽略BOM表,并将度符号渲染为“”。尽我们所能改变编码。