How do I enable GZIP compression for SOAP responses?

I created a simple web service using Spring

and CXF

. Now I am trying to enable GZIP compression for xml requests. The following will accept compressed requests, but the response will be uncompressed. Why?

@Component
@WebService
public class SoapService {

}

@Autowired
private SpringBus bus;


EndpointImpl end = new EndpointImpl(bus, new SoapService());
end.getFeatures().add(config.gzipFeature());
ep.publish("/SoapService");

      

Request for this 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], ...}

      

Answer (empty headers !!):

Content-Type: text/xml
Headers:
Payload: ...

      

Why isn't the answer compressed with gzip?

+3


source to share


1 answer


You need to add annotation @GZIP

to your interface. Here is the documentation . If I remember correctly, you need to have the GZIPOutInterceptor

spring specified in your config.



Alternatively, you can manually add the GZIPOutInterceptor to your endpoint.

+4


source







All Articles