client.addFilter(new LoggingFilter());
Voici un exemple complet :
@Grab('com.sun.jersey:jersey-client:1.8')
@Grab('com.sun.jersey:jersey-core:1.8')
@Grab('com.sun.jersey.contribs:jersey-apache-client4:1.8')
import com.sun.jersey.api.client.*;
import com.sun.jersey.api.client.filter.LoggingFilter;
import javax.ws.rs.core.*;
Client client = create();
client.addFilter(new LoggingFilter());
def resource = client.resource("http://geek-du-soir.blogspot.com").path("/feeds/posts/default")
resource.accept(MediaType.APPLICATION_XML).get(String.class);
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
import org.apache.http.conn.ssl.SSLSocketFactory;
import com.sun.jersey.client.apache4.ApacheHttpClient4;
import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config;
ApacheHttpClient4 create() {
DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
ApacheHttpClient4 jerseyClient = ApacheHttpClient4.create(config);
HttpClient httpClient = jerseyClient.getClientHandler().getHttpClient();
SSLSocketFactory sf = (SSLSocketFactory) httpClient.getConnectionManager().getSchemeRegistry().getScheme("https").getSchemeSocketFactory();
sf.setHostnameVerifier(new AllowAllHostnameVerifier());
return jerseyClient;
}
Aucun commentaire:
Enregistrer un commentaire