问题
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
回答1:
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
来源:https://stackoverflow.com/questions/37402492/how-to-process-gzip-from-soapui-in-wcf