这可能对您有所帮助,如果不是,我会删除答案。我认为这可以在你的情况下使用,但我不太确定,因为没有其他细节。
WebContentTypeMapper可用于覆盖正在发送的内容类型。这是削减WCF采样集中使用的代码。在这个例子中,它会接收任何发送的内容类型并将其映射到json,但您可以根据需要进行调整。
如果你没有它已经可以从WCF Samples 此示例位于..WF_WCF_Samples \ WCF \扩展下载Samples \阿贾克斯\ WebContentTypeMapper \ CS
using System.ServiceModel.Channels;
namespace Microsoft.Samples.WebContentTypeMapper
{
public class JsonContentTypeMapper : System.ServiceModel.Channels.WebContentTypeMapper
{
public override WebContentFormat GetMessageFormatForContentType(string contentType)
{
if (contentType == "text/javascript")
{
return WebContentFormat.Json;
}
else
{
return WebContentFormat.Default;
}
}
}
}
也许https://开头的社会.msdn.microsoft.com/Forums/vstudio/zh-CN/c1a29404-c990-482a-901f-dbfdf0d8f270/how-to-config-wcf-service-to-accept-non-unicode-encoding?forum = wcf –
https:/ /docs.microsoft.com/en-us/dotnet/framework/wcf/extending/custom-encoders –
@KScandrett这,再加上与该论坛帖子上接受的答案的作者谈话做了伎俩。 – DavidGouge