![](/img/trans.png)
[英]The content type application/xml;charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8), WCF
[英]Change WCF service to accept content-type “application/xml;charset=utf-8”
我创建了WCF服务,该服务将由需要接受内容类型application / xml; charset = utf-8和SOAP 1.1信封命名空间的第三方使用。 该服务当前正在接受text / xml; charset = utf-8。 让客户端更改内容类型不是一种选择。
除了设置basicHttpBinding maxReceivedMessageSize外,我没有对web.config文件进行任何更改。
<bindings>
<basicHttpBinding>
<binding name="http" maxReceivedMessageSize="2147483647"/>
</basicHttpBinding>
</bindings>
此问题通常是由于服务类型引起的。 传统的基于Web服务规范的SOAP Web服务,SOAP信封是通信载体, 内容类型是“ application / soap + xml”。 charset = utf-8”或“ text / xml; charset = utf-8” (与XML Web服务兼容)。
https://zh.wikipedia.org/wiki/SOAP
特定的HTTP标头在Restful样式服务中很常见。 WCF也可以创建一个宁静的样式服务。
https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/wcf-web-http-programming-model
例。
https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/how-to-create-a-basic-wcf-web-http-service
这是我曾经写过的一个例子。
如何通过Jquery调用C#WCF服务来修复“ ERR_ABORTED 400(错误请求)”错误?
请随时告诉我是否有什么我可以帮助的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.