java - 如何为 SOAP 响应启用 GZIP 压缩?

标签 java spring web-services soap cxf

我使用 SpringCXF 创建了一个简单的 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/

相关文章:

java - oracle.sql.TIMESTAMP 无法转换为 java.sql.Timestamp

java - WAR - Gradle 多模块应用程序 - TypeNotPresentException

java - 使用 JMockit 模拟 Autowiring 的接口(interface)实现

java - 如何使用 Spring MockMvc 放置多部分/表单数据?

web-services - 在浏览器刷新时编译 JSP 和 Java - Tomcat

java - Libgdx 设置正交相机

java - 返回上一页 图形用户界面

web-services - 从 F# 3.0 查询蛋白质数据库

java - 关于 hibernate 标准+限制的错误LazyInitializationException(Spring)

c# - 如何在sql查询中使用逗号分隔的动态字符串?