2015-01-10 152 views

回答

9

這裏是你如何使用CXF做到這一點:

import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; 
import org.apache.cxf.interceptor.LoggingInInterceptor; 
import org.apache.cxf.interceptor.LoggingOutInterceptor; 
import org.apache.cxf.jaxrs.client.ClientConfiguration; 
import org.apache.cxf.jaxrs.client.WebClient; 
import org.json.JSONException; 
import org.json.JSONObject; 
... 
    WebClient client = WebClient.create(endPoint, providers).accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON); 
    ClientConfiguration config = WebClient.getConfig(client); 
    config.getInInterceptors().add(new LoggingInInterceptor()); 
    config.getOutInterceptors().add(new LoggingOutInterceptor());