简体   繁体   English

更改WCF服务以接受内容类型“ application / xml; charset = utf-8”

[英]Change WCF service to accept content-type “application/xml;charset=utf-8”

I created WCF service that's going to be consumed by a third-party that needs to accept content-type application/xml;charset=utf-8 and SOAP 1.1 envelope namespace. 我创建了WCF服务,该服务将由需要接受内容类型application / xml; charset = utf-8和SOAP 1.1信封命名空间的第三方使用。 The service is currently accepting text/xml;charset=utf-8. 该服务当前正在接受text / xml; charset = utf-8。 Having the client change the content-type is not an option. 让客户端更改内容类型不是一种选择。

I haven't made any changes to the web.config file, except setting the basicHttpBinding maxReceivedMessageSize. 除了设置basicHttpBinding maxReceivedMessageSize外,我没有对web.config文件进行任何更改。

  <bindings>
      <basicHttpBinding>
        <binding name="http" maxReceivedMessageSize="2147483647"/>
      </basicHttpBinding>
    </bindings>   

This issue typically due to the service type. 此问题通常是由于服务类型引起的。 Traditional SOAP web service based on the web service specification, SOAP envelope is the communication carrier and content-type is “application/soap+xml; 传统的基于Web服务规范的SOAP Web服务,SOAP信封是通信载体, 内容类型“ application / soap + xml”。 charset=utf-8” or “text/xml;charset=utf-8” (for compatible with XML web service). charset = utf-8”“ text / xml; charset = utf-8” (与XML Web服务兼容)。
https://en.wikipedia.org/wiki/SOAP https://zh.wikipedia.org/wiki/SOAP
The specifical HTTP header is commonplace in the Restful style service. 特定的HTTP标头在Restful样式服务中很常见。 WCF could create a restful style service too. WCF也可以创建一个宁静的样式服务。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/wcf-web-http-programming-model https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/wcf-web-http-programming-model
Example. 例。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-create-a-basic-wcf-web-http-service https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/how-to-create-a-basic-wcf-web-http-service
Here is an example I ever wrote. 这是我曾经写过的一个例子。
How to fix "ERR_ABORTED 400 (Bad Request)" error with Jquery call to C# WCF service? 如何通过Jquery调用C#WCF服务来修复“ ERR_ABORTED 400(错误请求)”错误?
Feel free to let me know if there is anything I can help with. 请随时告诉我是否有什么我可以帮助的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 响应消息的内容类型 application/xml;charset=utf-8 与绑定的内容类型(text/xml; charset=utf-8)不匹配,WCF - 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 SILVERLIGHT WCF问题:内容类型application / soap + xml; charset = utf-8已发送到需要text / xml的服务; - SILVERLIGHT WCF Issue: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; WCF成员资格提供程序引发错误:内容类型&#39;application / json; charset = utf-8&#39;不是预期的类型&#39;application / soap + xml; 字符集= UTF-8&#39; - WCF Membership Provider throws error: content type 'application/json; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8' wcf +响应消息的内容类型text / html与绑定的内容类型不匹配(application / soap + xml; charset = utf-8) - wcf + The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8) WCF错误:(415)内容类型&#39;application / x-www-form-urlencoded&#39;不是预期类型&#39;application / soap + xml; 字符集= UTF-8&#39; - WCF ERROR: (415) content type 'application/x-www-form-urlencoded' was not the expected type 'application/soap+xml; charset=utf-8' 响应消息的内容类型application / xml; charset = utf-8与绑定的内容类型不匹配(text / xml; charset = utf-8) - 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) API Get 需要 Content-Type application/json;charset=UTF-8 - Http 客户端问题 - API Get requires Content-Type application/json;charset=UTF-8 - Issue with Http Client HTTP 415 无法处理消息,因为内容类型为“application/json; charset=utf-8&#39; 不是预期的类型 &#39;text/xml; 字符集=utf-8&#39; - HTTP 415 Cannot process the message because the content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8' 无法处理消息,因为内容类型为 &#39;application/json; charset=utf-8&#39; 不是预期的类型 &#39;text/xml; 字符集=utf-8&#39; - Cannot process the message because the content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8' 无法处理该消息,因为内容类型“ application / xml”不是预期的类型“ application / soap + xml”; 字符集= utf-8&#39; - Cannot process the message because the content type 'application / xml' was not the expected type 'application / soap + xml; charset = utf-8 '
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM