FastInfoset Using CXF

FastInfoset Using CXF explains about How to use FastInfoset encoding with CXF framework
FastInfoset is a binary encoding for an XML Information, It incorporated with a more efficiant serialization mechanism than text based
Using FastInfoset encoding is a much better solution than gzip encoding because FastInfoset optimize both size and performance, while gzip only deals with size
You can also see the GZIP Using CXF if you need to configure gzip compression
You can see the below example, which is demonstrating the usage of FastInfoset Using CXF
FastInfoset Using CXF
I am going to re-use CXF Web Service Tutorial
Following additional jar must be in classpath
- FastInfoset-1.2.16.jar (Available on CXF bundle)
For enabling FastInfoset, just change the service interface, For this you need to add the below annotations on service interface class
@FastInfoset
import javax.jws.WebService;
import org.apache.cxf.annotations.FastInfoset;
@FastInfoset
@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;
// Invoke CXF client with FastInfoset
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 Eclipse console is showing response with content type as content-type=[application/fastinfoset]