GZIP Using CXF
GZIP Using CXF explains about How to use GZIP compression with CXF framework
GZIP is a text-based encoding protocol which will compress the size of response dramatically
You can configure GZIP encoding with cxf framework according to the following configuration
You can also see the FastInfoset Using CXF, FastInfoset will result in a much better compression rate than gzip because FastInfoset optimize both size and performance, while gzip only deals with size
You can see the below example, which is demonstrating the usage of GZIP With CXF Framework
GZIP Using CXF
For enabling GZIP, just change the service interface, For this you need to add the below annotations on service interface class
@GZIP
import javax.jws.WebService;
import org.apache.cxf.annotations.GZIP;
@GZIP
@WebService
public interface ChangeStudentDetails {
Student changeName(Student student);
}
Run Client
import org.apache.cxf.ext.logging.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import com.student.ChangeStudentDetails;
import com.student.Student;
// GZIP Compression Using CXF
public final class StudentClient {
public static void main(String args[]) throws Exception {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ChangeStudentDetails.class);
factory.setAddress("http://localhost:8080/CXFTutorial/ChangeStudent?wsdl");
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
ChangeStudentDetails client = (ChangeStudentDetails) factory.create();
Student student = new Student();
student.setName("Rockey");
Student changeName = client.changeName(student);
System.out.println("Server said: " + changeName.getName());
System.exit(0);
}
}
Output
Here you can see that TCPMon tool to show the request / response structure, and see Content-Encoding as gzip