![](/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.