无法处理消息,因为内容类型“application/soap+xml;charset=UTF-8”不是预期的类型“application/soap+msbin1+gzip”

Cannot process the message because the content type 'application/soap+xml;charset=UTF-8 was not the expected type 'application/soap+msbin1+gzip'

提问人:Osprey1999 提问时间:10/26/2023 更新时间:10/26/2023 访问量:34

问:

我正在尝试在 IIS 上托管的 WCF 服务中实现 Gzip 压缩。

以前,绑定配置设置为 --

<customBinding>
    <binding name="SOAPBinding">
        <textMessageEncoding messageVersion="Soap11WSAddressing10" />
    </binding>
</customBinding>

现在为了实现压缩,我将绑定配置更改为 --

<customBinding>
    <binding name="SOAPBinding">
        <binaryMessageEncoding compressionFormat="GZip" />
    </binding>
</customBinding>

进行更改后,每当我尝试获取端点的响应(使用SOAP UI进行测试)时,它都会返回错误响应

Cannot process the message because the content type 'application/soap+xml;charset=UTF-8 was not the expected type 'application/soap+msbin1+gzip'.

使用前面的绑定配置,服务工作正常。一旦我更改了自定义绑定,它就会抛出错误。

预期是,当在请求中发送 Accept-Encoding : gzip 时,一旦启用压缩,服务应返回带有标头 Content-Encoding : gzip 的响应

.NET 压缩 gzip WCF 绑定

评论

0赞 QI You 10/30/2023
首先,我建议您将 soap 的版本更改为 Soap 1.1。那么我认为这篇文章可以帮助你解决问题。如何在 SoapUI / ReadyAPI 的请求正文中发送 ZIP 文件
0赞 Osprey1999 10/30/2023
如何在自定义绑定中将 soap 版本设置为 1.1 ?
0赞 QI You 10/31/2023
Web.Config **<binding> 下,有一个 <textMessageEncoding>可用于指定 Soap 版本。有关详细信息,请参阅此文档<textMessageEncoding>

答: 暂无答案