【问题标题】:How to process gzip from SoapUI in WCF?如何在 WCF 中处理来自 SoapUI 的 gzip?
【发布时间】:2023-03-20 08:08:02
【问题描述】:

我正在我的 WCF 中进行两种方式的 gzip 压缩。使用 IIS 的响应部分相当容易,但我似乎无法使用 SoapUI 处理请求。我使用 SoapUI 的原因是因为将要连接的客户端应用程序最终不会使用 Microsoft 堆栈。

我在这里创建了一个示例解决方案来演示问题 https://github.com/janmchan/WCFCompression

在解决方案中,我有一个 WCFServiceDemo(WCF 服务器)和 WCFClient(WCF 客户端)。对客户端/服务器都使用下面的绑定,我对请求/响应没有任何问题。

<bindings>
  <customBinding>
    <binding name="myBinding">
      <binaryMessageEncoding compressionFormat="GZip"/>
      <httpTransport decompressionEnabled="True" />
    </binding>
  </customBinding>
</bindings>

我通过此请求得到以下标头

2016-05-23 11:37;14 : Connection: Keep-Alive
Content-Length: 298
Content-Type: application/soap+msbin1+gzip
Accept-Encoding: gzip, deflate
Expect: 100-continue
Host: localhost:19860

但是,使用带有这些设置的 SoapUI

还有这个示例消息

我收到以下响应,表明内容类型不正确。我试过添加标题,但似乎不是解决方案。我也尝试添加一个模块来为Gzip压缩添加过滤器,但是在退出所有模块后它仍然会遇到错误。

我如何确保终端客户端可以连接到 WCF,类似于 SoapUI 的连接方式?

HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml;charset=UTF-8;action="http://tempuri.org/IService1/GetData"' was not the expected type 'application/soap+msbin1+gzip' Cache-Control: private
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?YzpcdXNlcnNcamNoYW5cZG9jdW1lbnRzXHZpc3VhbCBzdHVkaW8gMjAxNVxQcm9qZWN0c1xXY2ZTZXJ2aWNlRGVtb1xXY2ZTZXJ2aWNlRGVtb1xTZXJ2aWNlMS5zdmM=?=
X-Powered-By: ASP.NET
Date: Tue, 24 May 2016 00:04:19 GMT
Connection: close
Content-Length: 0

【问题讨论】:

    标签: c# wcf soapui


    【解决方案1】:

    经过几个选项后,我发现解决此问题的最佳方法是使用自定义 MessageEncoder。虽然我有一个工作示例here,但我仍然有一些标题丢失的问题,但基本上当这个问题得到解决时,它应该是这个问题的解决方案。

    Why are the soap headers missing when using Custom MessageEncoder

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-17
      • 2012-10-12
      • 2011-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-07
      相关资源
      最近更新 更多