use of org.apache.cxf.jaxrs.client.ClientConfiguration in project syncope by apache.
the class SyncopeClient method getService.
/**
* Creates an instance of the given service class, with configured content type and authentication.
*
* @param <T> any service class
* @param serviceClass service class reference
* @return service instance of the given reference class
*/
public <T> T getService(final Class<T> serviceClass) {
synchronized (restClientFactory) {
restClientFactory.setServiceClass(serviceClass);
T serviceInstance = restClientFactory.create(serviceClass);
Client client = WebClient.client(serviceInstance);
client.type(mediaType).accept(mediaType);
ClientConfiguration config = WebClient.getConfig(client);
config.getRequestContext().put(HEADER_SPLIT_PROPERTY, true);
config.getRequestContext().put(URLConnectionHTTPConduit.HTTPURL_CONNECTION_METHOD_REFLECTION, true);
if (useCompression) {
config.getInInterceptors().add(new GZIPInInterceptor());
config.getOutInterceptors().add(new GZIPOutInterceptor());
}
return serviceInstance;
}
}
use of org.apache.cxf.jaxrs.client.ClientConfiguration in project tesb-rt-se by Talend.
the class RESTClient method useOldRESTServiceWithNewClient.
/**
* New REST client uses old REST service
*/
public void useOldRESTServiceWithNewClient() throws Exception {
List<Object> providers = createJAXRSProviders();
org.customer.service.CustomerService customerService = JAXRSClientFactory.createFromModel("http://localhost:" + port + "/examples/direct/rest", org.customer.service.CustomerService.class, "classpath:/model/CustomerService-jaxrs.xml", providers, null);
// The outgoing new Customer data needs to be transformed for
// the old service to understand it and the response from the old service
// needs to be transformed for this new client to understand it.
ClientConfiguration config = WebClient.getConfig(customerService);
addTransformInterceptors(config.getInInterceptors(), config.getOutInterceptors(), true);
System.out.println("Using old RESTful CustomerService with new client");
customer.v2.Customer customer = createNewCustomer("Smith New to Old REST");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Smith New to Old REST");
printNewCustomerDetails(customer);
}
use of org.apache.cxf.jaxrs.client.ClientConfiguration in project midpoint by Evolveum.
the class AbstractRestServiceInitializer method prepareClient.
protected WebClient prepareClient(String username, String password) {
WebClient client = WebClient.create(ENDPOINT_ADDRESS, Collections.singletonList(getProvider()));
ClientConfiguration clientConfig = WebClient.getConfig(client);
clientConfig.getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
client.accept(getAcceptHeader());
client.type(getContentType());
createAuthorizationHeader(client, username, password);
return client;
}
use of org.apache.cxf.jaxrs.client.ClientConfiguration in project midpoint by Evolveum.
the class TestSchemaRestService method prepareClient.
@Override
protected WebClient prepareClient(String username, String password) {
WebClient client = WebClient.create(ENDPOINT_ADDRESS, Arrays.asList(jsonProvider, new PrimitiveTextProvider<>()));
ClientConfiguration clientConfig = WebClient.getConfig(client);
clientConfig.getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
client.accept(MediaType.APPLICATION_JSON_TYPE);
createAuthorizationHeader(client, username, password);
return client;
}
use of org.apache.cxf.jaxrs.client.ClientConfiguration in project midpoint by Evolveum.
the class TestSecurityQuestionChallengeResponse method getUserAdministrator.
private Response getUserAdministrator(String authorizationHeader) {
WebClient client = WebClient.create(ENDPOINT_ADDRESS, Arrays.asList(getProvider()));
ClientConfiguration clientConfig = WebClient.getConfig(client);
clientConfig.getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
client.accept(getAcceptHeader());
client.type(getContentType());
client.authorization(authorizationHeader);
client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value());
Response response = client.get();
return response;
}
Aggregations