如何在 WCF 中从 SoapUI 处理 gzip? [英] How to process gzip from SoapUI in WCF?

查看:43
本文介绍了如何在 WCF 中从 SoapUI 处理 gzip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我在这里创建了一个示例解决方案来演示问题

和这个示例消息

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

如何确保终端客户端可以像 SoapUI 的连接方式一样连接到 WCF?

HTTP/1.1 415 无法处理消息,因为内容类型 'application/soap+xml;charset=UTF-8;action="http://tempuri.org/IService1/GetData"' 不是预期类型 'application/soap+msbin1+gzip' 缓存控制:私有服务器:Microsoft-IIS/10.0X-AspNet 版本:4.0.30319X-SourceFiles: =?UTF-8?B?YzpcdXNlcnNcamNoYW5cZG9jdW1lbnRzXHZpc3VhbCBzdHVkaW8gMjAxNVxQcm9qZWN0c1xXY2ZTZXJ2aWNlRGVtb1xXY2Z5mTmxTb1xXY2Z5mTmxTZV =X-Powered-By: ASP.NET日期:2016 年 5 月 24 日,星期二 00:04:19 GMT连接:关闭内容长度:0

解决方案

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

为什么使用自定义时缺少soap标头消息编码器

I am working on two way gzip compression in my WCF. The response part is fairly easy with IIS but I can't seem to handle a request using SoapUI. The reason I'm using SoapUI is because the client app that will be connecting won't be using Microsoft stack on their end.

I have created a sample solution here to demonstrate the promlem https://github.com/janmchan/WCFCompression

In the solution I have a WCFServiceDemo (WCF Server) and WCFClient (WCF Client). Using the binding below for both client / server, I don't have any issue with request / response.

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

I get the following header with this request

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

However, using SoapUI with these settings

and this sample message

I get the following response which suggest the content type is incorrect. I've tried adding the headers but it doesn't seem to be the solution. I also tried adding a module to add the filter for Gzip compression, but it still encouters an error after exiting all the modules.

How do I make sure that and end client can connect to the WCF similar to how SoapUI is connecting?

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

解决方案

After going through several options, I discovered that the best way to resolve this is to use a custom MessageEncoder. Although I have a working sample here, I still have an issue where some headers are missing but essentially when this is resolved, it should be the solution to this problem.

Why are the soap headers missing when using Custom MessageEncoder

这篇关于如何在 WCF 中从 SoapUI 处理 gzip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆