问题描述
我一直在寻找一种方法,以向基于WebHttpBinding的客户端WCF REST Web服务接口中添加新行为.
我具有Java EE服务器,该服务器具有gzip(正常压缩强度)功能以进行响应.通常,这是内容协商".但是为了进行测试,我可以为所有响应(碰巧是XML文档)永久打开它.
我尝试了几种建议的将解压缩功能添加到客户端WCF的方法,但我遇到了几种方法之一问题.我尝试过的一些解决方案似乎与SOAP WS.*服务兼容,因此当与我的Web REST服务定义混合使用时,在创建服务通道时会导致运行时错误.
我基于添加WcfExtensions.ServiceModel.Channels.CompressionBindingElement
的最后一个解决方案,当我尝试使用此方法时,如果我调整Java EE服务器不压缩响应,则服务调用将从客户端开始.当我启用响应压缩时,出现以下形式的错误:"EndpointNotFoundException"
我对WCF并不十分熟悉,而REST支持方面的文档似乎实在有些薄
如果有人甚至可以确认可以做到这一点,并向我指出应该起作用的代码示例,那么我可能可以做剩下的事情(没有双关语)-目前,我不确定WCF框架中哪些是不可能的限制,哪些是我的测试代码中设置的错误或不正确.理想情况下,我想要一个与标准gzip Web服务器压缩兼容的解决方案,通常也受Web浏览器的支持,等等.
预先感谢您的帮助! :)
Hi,
I've been searching for a little while for a way to add a new behaviour to my client WebHttpBinding based WCF REST web service interface.
I have a Java EE server with gzip (normal compression strength) capability for responses. Normally this is "content negotiated" but for testing I can turn it on permanently for all responses (which happent to be XML documents).
I've tried several suggested methods of adding decompression to the client side WCF and I hit one of several problems. A few of the solutions I've tried seem to be compatible with SOAP WS.* servces, so when mixed with my web REST service definition cause a run time error when the service channel is being created.
The last solution I have based on adding the WcfExtensions.ServiceModel.Channels.CompressionBindingElement
When I try with this, if I adjust my Java EE server not to compress responses the service calls work from the client. When I enable compression of responses I get an error of the form: "EndpointNotFoundException"
I'm not massively familiar with WCF and the documentation on the REST support seems a little thin on the ground when it comes to customisations.
If someone can even confirm this can be done and point me at a sample of code that should work, I can probably do the rest (no pun intended) - at the moment I'm not sure what are impossible limitiations in the WCF framework and what are mistakes or incorrect set up in my test code. Ideally I'd like a solution that's compatible with standard gzip web server compression, as is normally support by web browsers too etc.
thanks for any help in advance! :)
推荐答案
这篇关于WCF REST(与WebHttpBinding兼容)客户端gzip压缩-从服务器解压缩Web响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!