我使用 Spring
和 CXF
创建了一个简单的 soap 网络服务。我现在正在尝试为 xml 请求启用 GZIP 压缩。
以下将接受压缩请求,但将响应未压缩。为什么?
@Component
@WebService
public class SoapService {
}
@Autowired
private SpringBus bus;
EndpointImpl end = new EndpointImpl(bus, new SoapService());
end.getFeatures().add(config.gzipFeature());
ep.publish("/SoapService");
请求这个 SoapService:
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml;charset=UTF-8
Headers: {accept-encoding=[gzip,deflate], content-encoding=[gzip], connection=[Keep-Alive], content-type=[text/xml;charset=UTF-8], ...}
响应(空标题!!):
Content-Type: text/xml
Headers:
Payload: ...
为什么没有使用 gzip 压缩响应?
最佳答案
您需要将@GZIP
注释添加到您的界面。 Here's the documentation .如果我没记错的话,您需要在 spring 配置中声明 GZIPOutInterceptor
。
或者,您可以添加 GZIPOutInterceptor手动到您的端点。
关于java - 如何为 SOAP 响应启用 GZIP 压缩?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26861801/